<%@ 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>My JSP 'test1.jsp' starting page</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">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
<script src="js/jquery-2.1.1.min.js" type="text/javascript">
</script>
</head>
<body>
<form action="#" id="form">
<div>
<input type="text" name="username" placeholder="用户名" id="usernmae"><br>
<input type="password" name="password" placeholder="密码" id="password"><br>
</div>
<div>
<input type="checkbox" name="all" id="all">全选
<input type="checkbox" name="all" id="all-res">全不选<br>
<input type="checkbox" name="perfer" id="perfer" value="篮球">篮球<br>
<input type="checkbox" name="perfer" id="perfer" value="羽毛球">羽毛球<br>
<input type="checkbox" name="perfer" id="perfer" value="乒乓球">乒乓球<br>
</div>
</form>
</body>
<script language="JavaScript">
$("form #all").click(function(){
var $s=$("form #perfer");
var $text="";
for(var i=0;i<$s.length;i++){
if($s[i].checked){
$text+=$s[i].value;
}else{
$($s[i]).attr("checked","checked");
}
}
$("form #all-res").removeAttr("checked");
alert($text);
});
$("form #all-res").click(function(){
var $s=$("form input[name='perfer']");
$($s).each(function(){
$(this).removeAttr("checked");
});
$("form #all").removeAttr("checked");
});
</script>
</html>
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。