The bind () method adds one or more event handlers to the selected element, and specifies the function to run when the event occurs.
$ (selector). bind (Event,data,function)//syntax
Event required. Specifies one or more events that are added to an element, separated by a space from multiple events. Must be a valid event:
data: Optional. Specifies additional data that is passed to the function.
function: required. Specifies the function to run when an event occurs.
$ ("button"). Bind ("click", Function () { $ ("P"). Slidetoggle ();});
The previous example hides or displays the P element when you click the mouse
2 syntax
$ (selector). Bind ({event:function, event:function, ...})
Event:function, Event:function,: Required. Specifies the event map, which contains one or more events added to the element, and functions that run when the event occurs.
$ (document). Ready (function () { $ ("button"). Bind ({ click:function () {$ ("P"). Slidetoggle ();}, Mouseover:function () {$ ("body"). CSS ("Background-color", "Red");}, Mouseout:function () {$ ("body"). CSS (" Background-color "," #FFFFFF ");} );});
The previous example hides or displays the P element when the mouse is clicked,
Obody background color turns red when mouse moves to button
Obody background color turns white when mouse button is removed
JQuery event bind () method