jQuery: make checkboxes act like radio buttons?

后端 未结 11 1613
栀梦
栀梦 2020-11-28 10:29

Is there a way to make checkboxes act like radio buttons? I assume this could be done with jQuery?



        
11条回答
  •  情深已故
    2020-11-28 11:13

    Use change event of checkbox and assign checked value for current selected checkbox:

    	$("input[type=checkbox]").change(function()
    	{
    		$("input[type=checkbox]").prop('checked',false);
    		$(this).prop('checked',true);
    	});
    .checkBoxb{
      float:left;
      clear:both;
      }
    
    
    
    
    

提交回复
热议问题