jQuery $(“.class”).click(); - multiple elements, click event once

前端 未结 18 1655
借酒劲吻你
借酒劲吻你 2020-11-29 00:01

I have multiple classes on a page of the same name. I then have a .click() event in my JS. What I want to happen is the click event only happen once, regardless of multiple

18条回答
  •  抹茶落季
    2020-11-29 00:37

    I just had the same problem. In my case PHP code generated few times the same jQuery code and that was the multiple trigger.

    Popraw / Zgłoś
    

    (PHP MULTIPLE GENERATER NUMBERS generated also the same code multiple times)

    
    

    My solution was to separate script in another php file and load that file ONE TIME.

提交回复
热议问题