jQuery bind() Method
The jQuery bind() is an inbuilt method that is used to attach one or more event handlers for selected element and this method specifies a function to run when event occurs.
$(selector).bind(event, data, function);
Parameter: It accepts three parameters that are specified below-
- event: This is an event type which is passed to the selected elements.
- data: This is the data which can be shown over the selected elements.
- function: This is the function which is perform by the selected elements.
Note This method has deprecated.
jQuery codes to show the working of bind() method:
Example 1: In the below code,”click” event are attached with the given paragraph using this method.
Example 2: In the below code, same “click” event is added but this time data is also passed to this method.