http://blog.csdn.net/zzq58157383/article/details/7721974
The dynamic event binding plug-in livequery can be used to register events or trigger callback functions for corresponding DOM elements. Not only the elements that match the selector are bound to events, but the elements that are later added via JavaScript are bound. When the element no longer matches the selector, Livequery automatically cancels the event registration, so that the developer no longer needs to focus on the source of the HTML element, just focus on how to write its bound events
Selecting a DOM element from the jquery selector will persist the Livequery plug-in in real time throughout the DOM range. This means that regardless of whether an element is previously present or dynamically loaded, events are bound, just like CSS adds a style to an element. At the same time, this plug-in is almost without the use of resources to do these functions
Livequery:http://plugins.jquery.com/project/livequery
How to use:
1. Introduction of Jquery.livequery.js
<script src= "Scripts/jquery-1.6.4.js" type= "Text/javascript" ></script>
<script src= "Scripts/jquery.livequery.js" type= "Text/javascript" ></script>
2. Dynamically binding events via Livequery
$ (document). Ready (function () {
$ (' a '). Livequery (' click ', function () {
Alert (' Livequery caused by click ');
return false;
});
$ ("Body"). Append (' <p><a href= ' # ' > Hyperlink b</a> ');
$ ("Body"). Append (' <p><a href= ' # ' > Hyperlink c</a> ');
});
The Livequery plugin can also trigger a callback function for a matching element, triggering another callback function when the element is no longer matched
$ (' Li '). Livequery (function () {
Binding mouseover and Mouseout events using the hover function
$ (this). Hover (function () {
$ (this). addclass (' hover ');
}, function () {
$ (this). Removeclass (' hover ');
});
}, function () {
Unbind MouseOver and Mouseout events
$ (This)
. Unbind (' mouseover ')
. Unbind (' mouseout ');
});
Use the Livequery plugin to register other plugins
if (jquery.livequery)
JQuery.livequery.resisterPlugin ("Method1", "Method2", "method3");
Different from the new live (type, fn) method in jQuery1.3:
1.live also binds an event handler (using delegation) to the current and future matching elements, and can also bind custom events. But the events currently supported are Click/dblclick, Mousedown/up/move/over/out, keydown/press/up, events not yet supported Blur/focus, Mouseenter/leave, Change, submit
The 2.live method does not support the "no event" style callback function provided by Livequery, and live can only bind event handlers
The 3.live method does not have "setup" and "cleanup" procedures, because all events are delegated rather than directly bound on the element.