我正在使用 on()
来模仿 live()
,但我一生都无法弄清楚如何正确引用 $(this )
因此它引用了我传入的选择器。这是代码,$(this)
返回 "body"
而不是 "select"
.
$("body").on("change", "select", function(e){
console.log($(this));
});
最佳答案
试试这个
$(e.currentTarget);
e 实际上是事件的事件参数,我相信这就是你想要的。
关于this - 使用 on() 时如何引用 $(this),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14251576/