當使用兩個複選框時,我可以一次限制一個複選框的選擇。如何使用多個複選框執行此操作? 繼承人我的javascript:限制選擇兩個以上覆選框
<script type="text/javascript">
$(document).ready(function(){
$('#checkbox1').click(function() {
var checkedBox = $(this).attr("checked");
if (checkedBox === true) {
$("#checkbox2").attr('checked', false);
} else {
$("#checkbox2").removeAttr('checked');
}
});
});
$(document).ready(function(){
$('#checkbox2').click(function() {
var checkedBox = $(this).attr("checked");
if (checkedBox === true) {
$("#checkbox1").attr('checked', false);
} else {
$("#checkbox1").removeAttr('checked');
}
});
});
$(document).ready(function(){
$('#checkbox3').click(function() {
var checkedBox = $(this).attr("checked");
if (checkedBox === true) {
$("#checkbox3").attr('checked', false);
} else {
$("#checkbox3").removeAttr('checked');
}
});
});
</script>
而我的HTML代碼爲波紋管
<i><input id="checkbox1" type="checkbox" name="checkbox1" value="gold" />
<label class="licencecheck" for="checkbox1"></label></i>
<i><input id="checkbox2" type="checkbox" name="checkbox2" value="gold" />
<label class="licencecheck" for="checkbox2"></label></i>
<i><input id="checkbox3" type="checkbox" name="checkbox3" value="gold" />
<label class="licencecheck" for="checkbox3"></label></i>
這是典型的'無線電buttons'一個用例:http://www.w3schools.com/html/tryit.asp?filename=tryhtml_radio – ppasler
html在哪裏? – ppasler
哦,該死的,對不起......讓我編輯 – RileyManda