jQuery对事件的反应不同?

时间:2019-11-28 18:58:03

标签: jquery click live

使用fullpage.js和createIT jQuery Paypal HTML Shop。 我的网站上有几个元素。使用以下方法时:

r.on("click touchend", function(r) {

一切正常,并将1个元素添加到购物车中。

现在,我需要动态删除和添加元素并尝试使用:

$(document).on('click touchend', r, function (r){   

但这会将所有元素添加到购物车中吗?

有什么主意如何处理?为什么两者之间会有区别?或如何制作

r.on("click touchend", function(r) {

是否将元素添加到文档中?

谢谢

1 个答案:

答案 0 :(得分:0)

 $(document).on('click touchend', ".ct-product-button", function (r){   
r.stopImmediatePropagation(),
r.preventDefault(),  

这就是对我有用的东西。