javascript - jquery selects one of the buttons of the same class to perform an operation.
漂亮男人
漂亮男人 2017-06-30 09:57:35
0
1
896
                         $(".parButton").each(function() {  
                             
                             $(this).bind("click",function(){
                                 
                                alert(1111);

                            
                             })
                        });
                        

".parButton"There are multiple Buttons. This will determine whether the currently clicked one can be selected. Why when I execute this line of code, the first ".parButton" Button is always executed multiple times.

漂亮男人
漂亮男人

reply all(1)
三叔

I have no problem running your code,

$(".parButton").each(function(index,item) {
    console.log(index);
    $(this).bind("click",function(){
        console.log(this);
         $(this).hide();
     })
});

I executed it like this, and one click disappears. Or is it a problem with the button? Can I try changing the button to p? Or you can print out the element you get every time you click to see if it is the element you clicked.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template