如果你有需要听众的动态元素,你可以这样做:
$(fixedElem).on(event, dynamicElem, function(e){
// Here 'this' is the dynamicElem that the event fired on
});
如何获得添加了侦听器的fixedElem
?
答案 0 :(得分:1)
您可以使用event.delegateTarget:
$(fixedElem).on("event", "dynamicElem", function(e) {
console.log(e.delegateTarget); // Here, fixedElem will be logged.
});