jQuery 1.8查找事件处理程序 [英] jQuery 1.8 find event handlers
本文介绍了jQuery 1.8查找事件处理程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何在jQuery 1.8 +中的对象上查找事件处理程序?
How to find event handlers on an object in jQuery 1.8+?
var func = function(){ alert(1); };
var obj = $('#obj');
obj.on("click", func);
// obj.data('events') is undefined
推荐答案
使用数据函数内部由jQuery完成。
在以前的版本中,您可以像其他数据一样调用它:
On previous versions, you could call it like for other data :
obj.data('events');
在jQuery 1.8中,此直接访问被删除,所以在最近的版本中,您必须这样调用:
In jQuery 1.8, this direct access was removed, so in recent versions you must call it like this :
$._data(obj[0], "events")
您可以通过打开控制台看到它在这个小提琴: http://jsfiddle.net/8TpeP/2/
You can see it in action by opening the console in this fiddle : http://jsfiddle.net/8TpeP/2/
这篇关于jQuery 1.8查找事件处理程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文