Home  >  Article  >  Web Front-end  >  jQuery method to determine whether a specified event is bound to an element_jquery

jQuery method to determine whether a specified event is bound to an element_jquery

WBOY
WBOYOriginal
2016-05-16 16:08:551060browse

The example in this article describes how jQuery determines whether a specified event is bound to an element. Share it with everyone for your reference. The details are as follows:

For example, the following code can determine whether the element with id=testdiv is bound to a click event. This determination is only valid for jQuery-bound events, and ordinary JS event binding is invalid.

//jQuery event封装支持判断元素上是否绑定了事件,此方法只适用于jQuery绑定的事件
var $events = $("#testdiv").data("events");
if( $events && $events["click"] ){
  //your code here
}

I hope this article will be helpful to everyone’s jQuery programming.

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