Home  >  Article  >  Web Front-end  >  Duplicate binding instructions for live methods in jQuery_jquery

Duplicate binding instructions for live methods in jQuery_jquery

WBOY
WBOYOriginal
2016-05-16 18:00:34940browse

Solution: Use the die() method to unbind all previously bound events on this element before binding the live() method, and then bind new events through the live() method.

Copy code The code is as follows:

//First release through the die() method , and then bind through live()
$("#selectAll").die().live("click",function(){
//Event running code
});

die() method introduction:
Copy code The code is as follows:

die([type], [fn])

Overview
New in jQuery 1.3. This method is exactly the opposite of live.

If no parameters are provided, all bound live events will be removed.

You can cancel custom events registered with live.

If the type parameter is provided, the corresponding live event will be removed.

If the second parameter function is also specified, only the specified event handling function will be removed.
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