Home > Web Front-end > JS Tutorial > body text

jQuery live_jquery

WBOY
Release: 2016-05-16 18:52:56
Original
1132 people have browsed it

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:

Copy code The code is as follows:

Click me !



jQuery code:
Copy code The code is as follows:

$("p").live("click", function(){
$(this).after("

Another paragraph!

");
});
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template