$(function (){
$("tr").click(function () {
if($(this).children().first().children().attr("checked")=="checked"){
$(this).children().first().children().removeAttr("checked")
}else{
$(this).children().first().children().attr('checked',true);
}
});
});
这段代码 在第一次加载页面的时候 点击TR 范围内是好使的 可以选择上 再次点击也可以取消选择 但是只能执行一次 在点击的时候虽然也在判断执行 可是页面是没有反应的没有 选择上
我也刚遇到过这个问题!已解决!
if (checked) {
$(this).prop("checked", true);
} else {
$(this).prop("checked", false);
}
看不懂你的话。
$("tr").click(function () {
//获取tr中第一个td中的checkbox框
var checkBox = $(this).find("td:first input[type='checkbox']");
if(checkBox.attr("checked")){
checkBox.remove("checked");
}else{
checkBox.attr("checked","checked");
}
});
你可以alert($(this).children().first().children().attr("checked")) 这个值看看,估计你就什么都知道了
可以用alert()调试
attr换成prop就可以了
attr换成prop就可以了