Home > Web Front-end > JS Tutorial > How jquery determines whether to bind an event

How jquery determines whether to bind an event

藏色散人
Release: 2022-12-30 11:12:45
Original
3485 people have browsed it

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. .

How jquery determines whether to bind an event

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以后才能用
Copy after login

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 
}
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template