Home > Article > Web Front-end > jQuery live_jquery
Custom events can also be bound. Currently supports click, dblclick, mousedown, mouseup, mousemove, mouseover, mouseout, keydown, keypress, keyup. It does not support blur, focus, mouseenter, mouseleave, change, submit
Different from bind(), live() can only bind one event at a time.
This method is very similar to traditional bind. The difference is that using live to bind events will bind events to all current and future elements on the page (using delegation). For example, if you use live to bind click events to all li on the page. Then when a li is added to this page in the future, the click event of this newly added li is still available. There is no need to re-bind events to this newly added element.
.live() is very similar to the popular liveQuery plug-in, but has the following main differences:
1. .live currently only supports a subset of all events, please refer to the support list above illustrate.
2. .live does not support the "no event" style callback function provided by liveQuery. .live can only bind event handling functions.
3. .live does not have "setup" and "cleanup" processes. Because all events are delegated rather than directly bound to elements.
4. To remove events bound with live, please use the die method
return value
jQuery
parameters
type (String): one or more Event names separated by spaces
fn (Function): Event processing function to be bound
Example
The p generated by clicking still has the same function.
HTML code:
Click me !
Another paragraph!
");