我想限制取消所有3個複選框的能力。jquery禁用剩餘的複選框時,2 3未經檢查
<input type="checkbox" value="one" checked> one
<input type="checkbox" value="two" checked> two
<input type="checkbox" value="three" checked> three
$(":checkbox").click(function() {
if ($("input:checked").length == 2){
$(':checkbox(:checked)').prop('disabled', false);
}else{
$(':checkbox(:checked)').prop('disabled', true);
}
});
我不能得到它來禁用最後一個複選框,因爲沒有被選中。 請幫忙!
爲什麼downvote? – BragDeal
我沒有downvote,但你的小提琴工作 – AmmarCSE
不,它禁用其他兩個再次檢查!我應該只允許我取消選中3中的2個,但我應該始終能夠檢查未選中的項目 – BragDeal