Why are two click events registered in this html/css/jquery

前端 未结 9 1848
清歌不尽
清歌不尽 2020-12-20 17:25

I am trying to style a checkbox list. I\'ve added my styles and they appear correctly when rendered. I want to add a class when the label for the checkbox is clicked. This i

9条回答
  •  悲哀的现实
    2020-12-20 17:43

    you can try this...

    $("label").find("*").click(function( event ) {
         event.stopPropagation();
    });
    
    $('label[for*=test_]').on('click',function(){
         $(this).toggleClass('test');
    });
    

提交回复
热议问题