jQuery 확인란의 전체 선택 및 반전:

2886 단어
jQuery 확인란의 전체 선택 및 반전:
캡처는 다음과 같습니다.
 
코드는 다음과 같습니다.
index.jsp:
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<title>        </title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<script src="http://code.jquery.com/jquery-latest.js"></script> 
<script type="text/javascript">
	$(function(){
		$("#checkAll").click(function(){
			$('[name=checkbox]:checkbox').attr("checked",true);
		});
		$("#checkNO").click(function(){
			$('[name=checkbox]:checkbox').attr("checked",false);
		});
	});
</script>
</head>

<body>
<table border="0" cellpadding="0" cellspacing="0">
	<tr>
		<td>
			<div align="left">
				<p>
				<input type="checkbox" name="checkbox" value="checkbox"/>  
				<input type="checkbox" name="checkbox" value="checkbox"/>  
				<input type="checkbox" name="checkbox" value="checkbox"/>  
				<input type="checkbox" name="checkbox" value="checkbox"/>  
				<input type="checkbox" name="checkbox" value="checkbox"/>  
				</p>
				<p>
				<input type="checkbox" name="checkbox" value="checkbox"/>  
				<input type="checkbox" name="checkbox" value="checkbox"/>  
				<input type="checkbox" name="checkbox" value="checkbox"/>  
				<input type="checkbox" name="checkbox" value="checkbox"/>  
				</p>
				<p align="right">
				<input type="button" name="Submit" id="checkAll" value="  "/>
				<input type="button" name="Submit2" id="checkNO" value="   "/>
				</p>
			</div>
		</td>
	</tr>
</table>
</body>
</html>

 

좋은 웹페이지 즐겨찾기