救助大神,javascript实现选中一个复选框后其他复选框不可用

用javascript实现选中其中一个复选框后,其他复选框不可用

<script>
$(':checkbox').change(function(){
    if($(this).is(':checked')){
        $(this).siblings().attr('disabled','disabled');
    }
    else {
        $(this).siblings().removeAttr('disabled','disabled');
    }
})
</script>

打酱油的路过, 貌似是用复选框完成单选框的任务

为其他复选框设置 disabled

楼上正解,找到除选中之外的所有复选框设置成disabled

选中事件都添加复选框不可用

 <script>
$(document).ready(function(){
   $("input[name='test']").click(function(){        
     $("input[name='test']").not(this).attr("disabled",$(this).is(':checked'))

    });


});
</script>


 <input type='checkbox'  name='test'>a
<input type='checkbox'  name='test'>b
<input type='checkbox'  name='test'>c