Home>Article>Web Front-end> How jquery determines whether to bind an event
How jquery determines whether an event is bound: First create a sample file; then use the "$(elem).data("events")[type]" statement to determine whether an event has been bound to the element. .
The operating environment of this tutorial: windows7 system, jquery1.2.6 version, DELL G3 computer.
Recommended:jquery video tutorial
jQuery Determine whether the event is bound to the element
Determine whether the event is bound to the element To pass an event, use the following statement
jQuery.data(elem,"events")[type] //老版本也能用 $(elem).data("events")[type] //1.2.3以后才能用
Return value:
An Object 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 jquery determines whether to bind an event. For more information, please follow other related articles on the PHP Chinese website!