Easy Tutorial
❮ Html Toggleclass Jquery Dimensions ❯

jQuery bind() Method

jQuery Event Methods

Example

Add a click event to a <p> element:

$("p").bind("click", function(){
    alert("This paragraph was clicked.");
});

Definition and Usage

The bind() method adds one or more event handlers to the selected elements and specifies a function to run when the events occur.

Since jQuery version 1.7, the on() method is the preferred way to attach event handlers to selected elements.


Syntax

Parameter Description
event Required. Specifies one or more events to add to the elements. <br> <br>Multiple event values are separated by spaces. Must be valid events.
data Optional. Specifies additional data to pass to the function.
function Required. Specifies the function to run when the event occurs.
map Specifies an event map ({event: function, event: function, ...}), containing one or more events to add to the elements, and the function to run when the events occur.

More Examples

Add Multiple Events

Use Event Map

Pass Data to Function


jQuery Event Methods

❮ Html Toggleclass Jquery Dimensions ❯