.click() fails after dom change

后端 未结 3 857
逝去的感伤
逝去的感伤 2020-12-20 21:22

I searched on web but I didn\'t find any answer since this \"problem\" is not the usual one about the difference between .on() and .click(). With jquery 2.1.3 the click func

3条回答
  •  旧巷少年郎
    2020-12-20 21:35

    The answer is if you added data dynamically, then you must use .on function. With this code, you can use event delegation concept by using the code that you mention at last. Since the DOM are not registered yet, the .click handler cant capture the new DOM element.

提交回复
热议问题