Home >Web Front-end >JS Tutorial >How to determine whether to bind an event in jquery
How jquery determines whether an event is bound: First create a js sample file; then use the statement "jQuery.data(elem,"events")[type]" to determine whether an event has been bound to the element. .
The operating environment of this tutorial: windows7 system, jquery1.10.0 version, Dell G3 computer.
Recommended: jQuery video tutorial
jquery determines whether an element is bound to an event
determines whether an event has been bound to an element Use the following statement
jQuery.data(elem,"events")[type] //老版本也能用 $(elem).data("events")[type] //1.2.3以后才能用
to return the value:
An Object, which can be traversed using for in. or undefined.
Parameters:
elem is a DOM object, type is the event type.
Example:
Determine whether the click event is bound to the element with id foo
if( $("#foo").data("events")["click"] ){ //your code }
The above is the detailed content of How to determine whether to bind an event in jquery. For more information, please follow other related articles on the PHP Chinese website!