我有2个按钮yes
和no
,只是我正在切换它们。单选按钮检查属性没有设置为假
<!DOCTYPE html>
<html>
<head>
<title>Demo Project</title>
</head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
<script src=""></script>
<script>
function enableCheckBoxAndDisableNoRadioButton() {
$(".checkbox").attr("checked",true);
$("#no").attr("checked", false);
}
function disableCheckBoxAnddisableYesRadioButton() {
$("#yes").attr("checked", false);
$(".checkbox").attr("checked",false);
}
</script>
<body>
<input class="checkbox" type="checkbox" >
<p>yes <input id="yes" type="radio" onchange="enableCheckBoxAndDisableNoRadioButton()"></p>
<p> no<input id="no" type="radio" checked=true onchange="disableCheckBoxAnddisableYesRadioButton()"></p>
</body>
</html>
当我点击yes
,那时没有按钮被取消选择,并且复选框被选中。 但是当我点击no
按钮时,那个时间复选框被取消选中,但是yes
按钮也被选中。我想让它取消选择。
让我知道是什么问题。
我在chrome上运行这段代码:53.0。