jQuery event delegation

后端 未结 4 2165
一向
一向 2020-11-27 08:40

I need some help with the callbacks. For some reason, they don\'t work really well.
I\'m making a game with jQuery. I have a

<
4条回答
  •  甜味超标
    2020-11-27 08:44

    Don't use the click(), use on('click') and attach it to the document.

    Creating a handler this way, will ensure that any new elements will be able to trigger the event.

提交回复
热议问题