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

How jquery determines whether to bind an event

藏色散人
藏色散人 Original
2021-01-28 09:14:45 3381browse

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

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!

Statement:
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
Previous article:jquery $.what does it mean Next article:jquery $.what does it mean