Jquery checkbox implements small radio examples

  • 2020-03-29 23:59:09
  • OfStack

 
$(function(){ 
$(':checkbox[name=flag]').each(function(){ 
$(this).click(function(){ 
if($(this).attr('checked')){ 
$(':checkbox[name=flag]').removeAttr('checked'); 
$(this).attr('checked','checked'); 
} 
}); 
}); 

}); 

<input name="flag" id="agree" type="checkbox" checked="checked" value="0"/>  Agreed to  
<input name="flag" id="reject" type="checkbox" value="1" />  Don't agree with  

Related articles: