YouTip LogoYouTip

Event Bind

# jQuery bind() Method [![Image 4: jQuery Event Methods](#) jQuery Event Methods](#) ## Example Add a click event to a

element: $("p").bind("click",function(){ alert("This paragraph was clicked."); }); [Try It Yourself Β»](#) * * * ## Definition and Usage The bind() method adds one or more event handlers to the selected elements, along with a function to run when the event occurs. As of jQuery version 1.7, the [on()](#) method is the preferred method for attaching event handlers to selected elements. * * * ## Syntax $(_selector_).bind(_event,data,function,map_) | Parameter | Description | | :--- | :--- | | _event_ | Required. Specifies one or more events to add to the elements. Multiple event values are separated by spaces. Must be a valid event. | | _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 functions to run when the events occur. | * * * ![Image 5: Examples](#) ## More Examples (#) How to add multiple events to an element. (#) How to use an event map to add some events/functions to the selected elements. (#) How to pass data to a custom named event handler. * * jQuery Event Methods](#)

← Css3 Pr Text WrapHtmldom Modify β†’