Click a div to check / uncheck a checkbox

前端 未结 5 687
执念已碎
执念已碎 2020-12-11 19:13

I applied the following code to make table rows check/uncheck a child checkbox when clicked. Now I discovered that when clicking the checkbox itself inside the row it doesen

5条回答
  •  情歌与酒
    2020-12-11 19:52

    I suspect that the click event is bubbling from the checkbox to the tr. Try adding this code as well:

    $('tr input[type=checkbox]').click(function(e){
            e.stopPropagation();
    });
    

    EDIT

    here's an example: http://jsfiddle.net/GSqNv/

提交回复
热议问题