jquery bind() method
Translation results:
bind
英[baɪnd] 美[baɪnd]
vt. Binding; restraining; binding; (with long strips of cloth) winding
vt.& vi. (to make) combine
n.Bind; dilemma, predicament; plant’s vine
jquery bind() methodsyntax
Function: bind() method adds one or more event handlers to the selected element and specifies the function to run when the event occurs.
Description: Specifies one or more event handlers to add to the selected element, and the function to run when the event occurs.
Syntax: $(selector).bind(event,data,function)
Parameters:
Parameters | Description |
event | Required. Specifies one or more events to be added to the element. Multiple events separated by spaces. Must be a valid event. |
data | Optional. Specifies additional data to be passed to the function. |
function | Required. Specifies a function to run when an event occurs. |
Alternative syntax: $(selector).bind({event:function, event:function, ...})
Parameters: {event:function, event:function, ...} Required. Specifies an event map that contains one or more events to add to the element, and a function to run when the event occurs.
jquery bind() methodexample
<html> <head> <script type="text/javascript" src="http://apps.bdimg.com/libs/jquery/2.1.1/jquery.min.js"></script> <script type="text/javascript"> $(document).ready(function(){ $("button").bind("click",function(){ $("p").slideToggle(); }); }); </script> </head> <body> <p>This is a paragraph.</p> <button>请点击这里</button> </body> </html>
Click the "Run instance" button to view the online instance