One, event binding
The JQ event bindings before jq1.7 are implemented by the Bind method, as follows
$ (' selector '). Bind (' EventType ', data, CallBack);
Pairing method Unbind
jqury1.7 before a similar pre-bound live, it is implemented by bubbling way, as follows
$ (' selector '). Live (' EventType ', Data, callBack);
Pairing method die
The event agent in Jqury, as follows
$ (' selector '). Delegate (' Childdom ', Eventtype,data, callBack);
Pairing Method Ondelegate
1.7 After the on method, using the on method binding way is also similar
$ (' selector '). On (' EventType ', Selector,data, callBack);
Pairing method off
Difference:
The 1.bind method is used to bind events to selected elements and cannot bind elements that do not yet appear
The 2.live method is implemented by event bubbling, which can bind elements that are not currently present (pre-bound) and discard after 1.7
3.delegate dedicated to event broker
4.on integrates the above three methods (for 1.7 later)
Ii. Custom Events
Custom events in Jqury do not need to be declared, bind directly using bind or other above methods, as follows
$ (window). bind (' Love ', function () {//Bind custom event, window here can be any object
Alert (' Love ');
});
$ (window). Trigger ("Love");//Touch a custom event
Usage scenarios:
The main idea is to solve the basic events in the browser can not complete the requirements, generally used for component outward exposure events, to achieve decoupling.
About the events of jquery