$(document).ready(function(){
/*$("#qx").toggle(function(){*/
$("checkbox[qx]").attr("checked", true);
$("[name=checkbox]:checkbox").attr("checked", true);
},
function(){
/*$("#qx").attr("checked", false);*/
$("[name =checkbox]:checkbox").attr("checked", false);
}
);
});
大概意思就是找到id="qx"的复选框,点一下全选,再点反选,功能可以实现,但是id="qx"的复选框,始终是未选状态,加上那段注释的代码也不行,求大神帮忙看看。
分不多了,在线等,大家帮帮忙= =
/*$("#qx").toggle(function(){*/
$("checkbox[qx]").attr("checked", true);
$("[name=checkbox]:checkbox").attr("checked", true);
},
function(){
/*$("#qx").attr("checked", false);*/
$("[name =checkbox]:checkbox").attr("checked", false);
}
);
});
大概意思就是找到id="qx"的复选框,点一下全选,再点反选,功能可以实现,但是id="qx"的复选框,始终是未选状态,加上那段注释的代码也不行,求大神帮忙看看。
分不多了,在线等,大家帮帮忙= =
/*$("checkbox[qx]").attr("checked", true);*/
包括$("[name=qx]:checkbox").attr("checked", true);
这样都是不行的,我贴一下jsp代码,大家再帮忙看看,谢谢了
<input type="checkbox" name="qx" value="checkbox" id="qx" />
全选</span></td>
$("qx").each(function()
{
$(this).attr("checked",true);
})
$("qx").click(function(){
if(this.attr("checked")){
$(".cb").attr("checked","checked");
}else{
$(".cb").removeAttr("checked");
}
});<input type="radio" id="qx"/>
<input type="checkbox" class="cb"/>
<input type="checkbox" class="cb"/>
<input type="checkbox" class="cb"/>
<input type="checkbox" class="cb"/>
<input type="checkbox" class="cb"/>
这是一段非常简单的代码,感觉好像可以实现你的功能了,当然我没试,只是现写的,你可以试一下。感觉你上面的逻辑看起来好像有点复杂化了。
还有就算取出的直是true 或者 false if的时候也要反过来
$("[name=checkbox]:checkbox").attr("checked", this.checked);
谢谢大家