您好,登錄后才能下訂單哦!
<%@ 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進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。