当前位置:首页 >> 网络编程

JQuery1.8 判断元素是否绑定事件的方法

On previous versions, you could call it like for other data :

obj.data('events');

In jQuery 1.8, this direct access was removed, so in recent versions you must call it like this :

$._data(obj[0],"events")

大概的意思是版本可以使用obj.data('event'); JQuery1.8版本取消了obj.data方法,改为$._data方法

注意:$._data(obj[0],"event") 中的obj[0],一定要加上数组[0]下标,否则会取不到数据
-------以下为举例

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<script src="/UploadFiles/2021-04-02/jquery-1.8.0.min.js">