无论如何,我可以检查现有元素是否附加了事件处理程序吗?假设一个简单的javascript方法向某个div.example(无jquery)添加了一个点击事件,因此没有属性标签,那么是否可以使用jquery捕获附加的事件?我尝试使用下面的代码来完成此操作,但没有成功:
$( '.example' ).each( function() {
var newObj = $(this);
$.each($(newObj).data("events"), function(i, event) {
alert(i);
$.each(event, function(j, h) {
alert(h.handler);
});
});
});
Try this
$( '#elm1' ).each( function() {
$.each($(this).data("events"), function(i, event) {
alert(i);
$.each(event, function(j, h) {
alert(h.handler);
});
});
});
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)