解决Js添加点击事件执行两次问题

在js写组件的时候遇到jQuery操作Dom点击事件的时候执行了两次,使用阻止冒泡e.stopPropagation(),e.preventDefault(),return false都没有用,最后找到方法:用.off().on(),完美解决。

$("xx").off("click","xx").on("click","xx",function() {
    //..........
})

猜你喜欢

转载自blog.csdn.net/qq_37300451/article/details/85131290