JQuery1.8 is used to determine whether an element is bound to an event. jquery1.8 is bound to an event.
On previous versions, you can call it like for other data:
Obj. data ('events ');
In jQuery 1.8, this direct access was removed, so in recent versions you must call it like this:
$. _ Data (obj [0], "events ")
In general, the version can use obj. data ('event'). In JQuery1.8, the obj. data method is canceled and changed to the $. _ data method.
Note: In $. _ data (obj [0], "event"), obj [0] must be added with the array [0] subscript. Otherwise, no data can be obtained.
------- The following is an example
<Html xmlns = "http://www.w3.org/1999/xhtml">
How can I use jQuery to determine whether an event is bound to an element?
For details about how to determine whether an event is bound, refer. The research found that all events were initiated. In fact, it was also designed to prevent memory overflow and the speed of page unload, as well as to trigger multiple functions and facilitate management. For details, refer to this article. JQuery will unmount all bound events during window. unload to release the memory. To determine whether an event has been bound to an element, use the following statement: view sourceprint for dededecms training on Alibaba Cloud? JQuery. data (elem, "events") [type] // the old version can also use $ (elem ). data ("events") [type] // 1.2.3 before using 51hsycn return value:
An Object can be traversed using for in. Or undefined.
Parameter: elem is an object and type is an event type.
For example, determine whether a click event is bound to an element whose id is foo:
JQuery checks whether an event is bound to an element.
To determine whether an event has been bound to an element, use the following statement jQuery. data (elem, "events") [type] // the old version can also use $ (elem ). data ("events") [type] // 1.2.3 before return value: an Object can be traversed using for in. Or undefined. Parameter: elem is a DOM object and type is an event type. For example, determine whether a click event if ($ ("# foo") is bound to an element whose id is foo "). data ("events") ["click"]) {// your code}