<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title></title>
<meta charset="utf-8">
<script type="text/javascript" src="jquery-1.7.2.min.js"></script>
</head>
<body>
<h2>根据被选中的 radio 值,设置 checkbox 是否可用</h2>
<hr>
<input type="radio" οnclick="setDeny(this)" name="fileType" value="1" />1
<input type="radio" οnclick="setDeny(this)" name="fileType" value="2" />2
<input type="radio" οnclick="setDeny(this)" name="fileType" value="3" />3
<hr>
<input name="check1" value="1" type="checkbox" id="check1"/>
<input name="check1" value="2" type="checkbox" id="check2"/>
<input name="check1" value="3" type="checkbox" id="check3"/>
<script>
function setDeny(obj) {
var radioValue = $(obj).val();
$('input[name="check1"]').each(function () {
$(this).attr("disabled", false);
$(this).attr("checked", false);
});
if(radioValue==1) {
$("input[name$='check1'][value$='1']").attr('disabled',true);
} else if(radioValue==2) {
$("input[name$='check1'][value$='2']").attr('disabled',true);
} else {
$("input[name$='check1'][value$='3']").attr('disabled',true);
}
}
</script>
</body>
</html>
根据被选中的 radio 值,设置 checkbox 是否可用
最新推荐文章于 2022-11-06 08:13:29 发布