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

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

    Ok so what I said in the comment. It generates two click events, do this instead and it works like a charm: Fiddle

    $('input').on('click',function(){
       console.log("clicked");
        $('div#target').append($(this).parent().clone());    
    });
    

    You might want to rename your inputs.

提交回复
热议问题