$('#parent1').click(function () {
if ($('#parent1').is(':checked')) {
$('input[type="checkbox"]').attr('checked', true);
} else {
$('input[type="checkbox"]').attr('checked', false);
}
});这个函数虽然不是document.ready(函数)的一部分,但只是第一次工作。
它不适用于后续的点击?这里有遗漏什么吗?任何帮助都将不胜感激。
我所有的子复选框都是父母2,3,4,...15。
<c:forEach var="parent1" items="${model.list}">
<form:checkbox path="list" value="${parent1.name}" label="${parent1.name}" />
</for:each>发布于 2015-05-16 03:57:11
尝试使用.prop()而不是.attr(),.attr()是不一致的。
$('#parent1').change(function () {
$('input[type="checkbox"]').prop('checked', this.checked);
});https://stackoverflow.com/questions/30271511
复制相似问题