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

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 250
    Comment on it

    Bind() method:

    Bind method is used to attach events to selected elements and also used to specify a function when the event occurs.

    Syntax:

    $(selector).bind(event,data,function,map)

    Example:

    <!DOCTYPE html>
    <html>
    <head>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
    <script>
    $(document).ready(function(){
        $("button").bind("click", function(){
            alert("Hello");
        });
    });
    </script>
    </head>
    <body>
    <p>Bind Method Example</p>
    <button>Click to see message</button>
    
    </body>
    </html>

    In the above example a method has been attached to button using bind() method. When user will click on button a alert will appear.

    You can check above example output here: https://jsfiddle.net/0dpafkkp/

 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: