jquery 操作 checkbox

html脚本
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<script type="text/javascript" src="http://apps.bdimg.com/libs/jquery/1.10.2/jquery.min.js"></script>
<script type="text/javascript"> 
 
$(document).ready(function(){
    //$("p:eq(1)").css("background-color","#B2E0FF");
});
 
$(document).on('click', "input[name=zoneType]", function() {  
					   if ($(this).val()=='') {
                          $('input[name=zoneType]').each(function() {
								if ($(this).val()!=''){
								  $(this).removeAttr('checked');
								 }
						       });
                       }else{
					   $('input[name=zoneType]').eq(0).removeAttr('checked');
					   }
				});
</script>	
 
</head>
<body>
<html>
<body>
<h1>Welcome to My Homepage (选择所有时选项1.2.3不能选中),选择选项1.2.3时所有不能选中 </h1>
<input type="checkbox" name="zoneType"  checked="checked" value="">所有
<input type="checkbox" name="zoneType"   value="1">选项1
<input type="checkbox" name="zoneType"   value="2">选项2
<input type="checkbox" name="zoneType"   value="3"> 选项3

猜你喜欢

转载自anlinko.iteye.com/blog/2343786