jquery 解决使用append添加元素后监听事件消失的问题

假设想要在id为target的div中append一个元素
原监听事件格式为:

$(".textBox").mouseover(function() {});

修改为:

$("#target").on("mouseover", ".textBox", function() {});

注意:id为target的盒子一定要一直存在,而不是后期动态添加的盒子!!!实在不行你就放body

猜你喜欢

转载自blog.csdn.net/baidu_27280587/article/details/56486619