Home  >  Article  >  Web Front-end  >  What is the usage of live in jquery

What is the usage of live in jquery

WBOY
WBOYOriginal
2022-03-22 16:03:591441browse

In jquery, the live() method is used to add event handlers to elements and specify the function to be run when the event occurs. The syntax is "$(selector).live(event,data,function to run)" "; This method was removed in jquery version 1.9 and can be replaced by the on() method.

What is the usage of live in jquery

The operating environment of this tutorial: windows10 system, jquery3.2.1 version, Dell G3 computer.

What is the usage of live in jquery

The live() method attaches one or more event handlers to the selected elements and specifies the functions to be run when these events occur.

Event handlers attached via the live() method apply to current and future elements matching the selector (such as new elements created by scripts).

Syntax

$(selector).live(event,data,function)

The parameters are expressed as follows:

event is required. Specifies one or more events to attach to the element. Multiple events separated by spaces. Must be a valid event.

data is optional. Specifies additional data to be passed to this function.

function required. Specifies a function to run when an event occurs.

The live() method is deprecated in jQuery version 1.7 and removed in version 1.9. Please use the on() method instead.

Examples are as follows:







这是一个段落。

Recommended related video tutorials: jQuery video tutorial

The above is the detailed content of What is the usage of live in jquery. For more information, please follow other related articles on the PHP Chinese website!

Statement:
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