我有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。