87,995
社区成员
发帖
与我相关
我的任务
分享
tf.selector=undefined


目前脚本测试的是TopJUI前端框架页面。如图,能获取到id="tree1365"的点击事件,不能获取到li元素存在点击事件。
function isBind(ele,en) {
ele = $(ele);
var eo = $._data(ele[0],"events");
if (eo && en in eo)
return true;
var ps = ele.parents().get()
ps.push(document,window);
return ps.some(function(t){
var eo = $._data(t,"events");
if (eo && en in eo) {
return eo[en].some(function(tf){
return $(tf.selector,t).is(ele);
});
}
});
}
alert(isBind($("#id"),"click"));

你这个语法跟$.data(ele, 'events') || $._data(ele, 'events');其实是一样的,委托的拿不到事件。window.document.body.addEventListener("onclick",function(){console.log("click0")})
$("body").click(function(){
console.log("click1");
});
console.log($._data($("body")[0]));