JavaScript has a very important function, which is event-driven. When the page is fully loaded, the user triggers the element of the bound event in the page by the mouse or keyboard. JQuery is a great way for developers to write event behavior more efficiently, encapsulating a number of useful event methods for our use.
One, event binding
JQuery uses the. bind () method to bind these events to an element. Three parameters can be passed: Bind (type, [data], FN), type represents one or more types of event name strings, [data] is optional and is passed as an additional data as the Event.data property value , which is a string, a number, An array or an object; FN represents a handler that is bound to a defined element.
<Scripttype= "Text/javascript"src= "Http://ajax.googleapis.com/ajax/libs/jquery/1.4.0/jquery.min.js"></Script><Scripttype= "Text/javascript"> $(function(){ //Use Click events /*$ (' input '). Bind (' click ', function () {Alert ("click"); }); */ //General processing Functions /*$ (' input '). Bind (' click ', FN); function fn () {alert ("click"); } */ });</Script></Head><Body> <inputtype= "button"value= "click" /></Body>
Multiple events can be bound at the same time