gpt4 book ai didi

javascript - jQuery 委托(delegate)事件绑定(bind)不起作用?

转载 作者:行者123 更新时间:2023-11-27 22:32:24 26 4
gpt4 key购买 nike

我正在使用 jQuery 2.2.4。我的页面中有三个 .note_edit 元素,在页面加载后动态添加(它们是 CartoDB infowindows 的一部分)。

我在控制台中使用以下代码来检查元素是否存在,它们确实存在:

$("body .note_edit");

然后我尝试在控制台中添加动态事件,如下所示:

$('body').on('click', '.note_edit', function(e) { e.preventDefault(); console.log('whatever'); });

但是当我单击元素时,没有任何反应 - 没有控制台输出。

这里可能出了什么问题?控制台中没有任何其他 JS 错误,这些元素肯定存在...可能是什么?

enter image description here

最佳答案

检查绑定(bind)到元素的其他事件。 Can I find events bound on an element with jQuery?

我怀疑有一个 e.stopPropagation() 阻止了 body 的访问。

关于javascript - jQuery 委托(delegate)事件绑定(bind)不起作用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39441525/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com