<input type="radio" id="chkMain" name="chkMain"/>
<input type="radio" id="chkMain1" name="chkMain" />
<input type="radio" id="chkMain2" name="chkMain" />
<input class="child" type="checkbox" id="chk1" disabled="true" />
<input class="child" type="checkbox" id="chk2" disabled="true" />
<input class="child" type="checkbox" id="chk3" disabled="true" />
<input class="child" type="checkbox" id="chk4" disabled="true" />
<input class="child" type="checkbox" id="chk5" disabled="true" />
<input class="child" type="checkbox" id="chk6" disabled="true" />
<input class="child" type="checkbox" id="chk7" disabled="true" />
<input class="child1" type="radio" id="tone1" disabled="true"/>
<input class="child1" type="radio" id="tone2" disabled="true"/>
<input class="child1" type="radio" id="tone3" disabled="true"/>
$(function()
{
$("input[id^='chkMain']").onclick(function() {
//var otherCks = $("input[id^='chkMain']").not(this);
if ($(this).is(":checked")) {
$(".child").attr("disabled", true);
otherCks.removeAttr("disabled");
} else {
$(".child").removeAttr("disabled");
otherCks.attr("disabled", true)
}
});
$("#chk_all").click(function() {
var checked_status = this.checked;
$("input[id^=chk]").each(function () {
this.checked = checked_status;
});
});
});
答案 0 :(得分:1)
像
这样的东西$(function(){
$("input:radio[name='chkMain']").change(function(){
if (this.checked) {
$("input:checkbox.child, input:radio.child1").removeAttr("disabled");
}
else {
$("input:checkbox.child, input:radio.child1").attr("disabled", "disabled");
}
});
});