Why is the onClick event triggered twice?

前端 未结 10 1250
夕颜
夕颜 2021-02-05 02:40

I have the following html:


    
&         


        
10条回答
  •  温柔的废话
    2021-02-05 03:04

    I had the same problem. Mine was the fact that I was using .trigger('.element') and there were two elements with that element class.

    So, I got more specific, and used .trigger('.parent .element') to ensure only one click event happened on a single element, instead of one click event on two elements.

提交回复
热议问题