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.