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

前端 未结 9 1849
清歌不尽
清歌不尽 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:56

    That's because you're binding event on label which contains checkbox and you're using for="chekbox_id". So, the event is fired for label as well as for checkbox.

    Take the input out of label.

    Demo: http://jsfiddle.net/tusharj/fdm1pmj2/5/

提交回复
热议问题