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

前端 未结 18 1682
借酒劲吻你
借酒劲吻你 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:45

    This should fix it and should be a good habit: .unbind()

    $(".addproduct").unbind().click(function(){
       //do something 
    });
    

提交回复
热议问题