addEventListener firing multiple times for the same handle when passing in arguments with anonymous function

后端 未结 3 1530
迷失自我
迷失自我 2020-12-15 23:26

For some reason, the event listener is firing twice for each element when passing arguments into an anonymous function. I.e., the click event on element el will

3条回答
  •  误落风尘
    2020-12-16 00:12

    addEventListener registers as many listeners as it is used.

    According to the documentation it takes 3 arguments, the third is useCapture which has nothing to do with registering listener twice or not. It is by default set to false, so adding false as a third parameter doesn't change much.

提交回复
热议问题