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

    • 0
    • 3
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 520
    Comment on it

    The on() method is used to attach one or more event handlers for the selected elements. It is designed to replace both the .bind() and .delegate() event handlers.

    Syntax:

    $(selector).on(event,childSelector,data,function,map)
    

    where

    PARAMETER DESCRIPTION Required/Optional
    event Can attach one or more events to the selected elements separated with spaces. Required
    childSelector It determines that an event handler should attached to the specified child elements Optional
    data For additional data Optional
    function Specifies the function to run at the time when an event occurs Required
    map Use to map one or more events to the selected elements and to run the function when events occur Optional

     

    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").on("click", function()
        {
            $(this).css("background-color", "#cccccc");
        });
    });
    
    </script>
    </head>
    <body>
    

 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: