For details about how to determine whether an event is bound, refer. After studying it, I found that jQuery caches events to prevent memory overflow and the speed of page unload, including multiple function triggers, convenient management and many other benefits. For details, refer to this article.
JQuery will unmount all bound events during window. unload to release the memory.
OK. Use the following statement to determine whether an event has been bound to an element:
The Code is as follows:
JQuery. data (elem, "events") [type] // the old version can also be used.
$ (Elem). data ("events") [type] // 1.2.3 later
Return Value:
An Object can be traversed using for in. Or undefined.
Parameters:
Elem is a DOM object and type is an event type.
Example:
Determine whether a click event is bound to an element whose id is foo.
The Code is as follows:
If ($ ("# foo"). data ("events") ["click"]) {
// Your code
}