作者:374439252亮 | 来源:互联网 | 2023-09-09 11:58
Iappliedthefollowingcodetomaketablerowscheckuncheckachildcheckboxwhenclicked.NowId
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 doesent check. Could it be that it checks on click (standard function) and then the jquery picks up the click event and unchecks it? How can I fix this?
我应用以下代码在单击时检查/取消选中子复选框。现在我发现,当在行中单击复选框本身时,它不会进行检查。它是否可以检查单击(标准函数),然后jquery获取单击事件并取消检查?我该怎么解决这个问题呢?
//check on div click
$("tr").live("click",function() {
var checkbox = $(this).find("input[type='checkbox']");
if( checkbox.attr("checked") == "" ){
checkbox.attr("checked","true");
} else {
checkbox.attr("checked","");
}
});
4 个解决方案