本文實例講述了jQuery實現復選框成對選擇及對應取消的方法。分享給大家供大家參考。具體實現方法如下:
			 
			復制代碼代碼如下:
			<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
		<html xmlns="http://www.w3.org/1999/xhtml">
		<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<title>jQuery實現復選框成對選擇,對應取消功能</title>
		<script type="text/javascript" src="/js/jquery-1.6.2.min.js"></script>
		<script>
		$(function(){
		 var classA = $(".classA");
		 classA.change(function(){
		  classA.attr("checked",Boolean($(this).attr("checked")));
		 })
		 var classB = $(".classB");
		 classB.change(function(){
		  classB.attr("checked",Boolean($(this).attr("checked")));
		 })
		})
		</script>
		</head>
		<body>
		<p>A組</p>
		<input type="checkbox" class="classA">
		<input type="checkbox" class="classA">
		<p>B組</p>
		<input type="checkbox" class="classB">
		<input type="checkbox" class="classB">
		</body>
		</html>
			 
			希望本文所述對大家的jQuery程序設計有所幫助。