Currently, click, dblclick, mousedown, mouseup, mousemove, mouseover, mouseout, keydown, keypress, and keyup are supported.
Blur, focus, mouseenter, mouseleave, change, and submit are not supported.
Unlike bind (), live () can only bind one event at a time.
This method is similar to the traditional bind method. The difference is that using live to bind events will bind events to all current and future elements on the page (using the delegate method ). For example, if you bind a click event to all the likes on the page with live. When a new li is added to this page, the click event is still available for the newly added li. Instead of re-binding events to the newly added elements.
. Live () is similar to the popular liveQuery plug-in, but there are several major differences:
*. Live currently only supports a subset of all events. For the list of supported events, see the preceding description.
*. Live does not support callback functions in the "no event" style provided by liveQuery .. Live can only be bound to event handlers.
*. Live does not have "setup" or "cleanup" processes. Because all events are delegate rather than directly bound to elements.
To remove an event bound with live, use the die method.
Return Value
JQuery
Parameters
Type (String): one or more event names separated by Spaces
Fn (Function): The event processing Function to be bound.
Example
The p generated by clicking still has the same function.
HTML code:
<P> Click me! </P>
JQuery code:
Copy codeThe Code is as follows:
$ ("P"). live ("click", function (){
$ (This). after ("<p> Another paragraph! </P> ");
});