Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • JQuery click() method

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 136
    Comment on it

    To assign a click event to all paragraphs we use this method. this is the syntax:
    $("p").click();

    now, in next step when an event fires, You must pass a function to this event:
    $("p").click(function(){ });

    $(document).ready()

    The $(document).ready() method executes a function when the document is fully loaded.

    click()
    The function gets executed when the user clicks on the HTML element.
    Example

    <!DOCTYPE html>
    <html>
    <head>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
    <script>
    $(document).ready(function(){
        $("p").click(function(){
            $(this).hide();
        });
    });
    </script>
    </head>
    <body>
    
    <p>If you will click it will disappear. </p>
    <p>Click me too!</p>
    <p>and now!</p>
    
    </body>
    </html>
    

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: