<%@ 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 'text.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 type="text/javascript" src="<%=path %>/static/js/jquery-1.11.3.min.js"></script>
<script type="text/javascript">
$(document).ready(function()
{
$("#btn").on("click",function()
{
$("form div").remove();
//js
//arr=document.getElementsByTagName("div");
//for(i=arr.length-1;i>=0;i--){
//js:得到父元素,通过父元素将子元素删除
//if(arr[i].parentNode.tagName=="Form"){
// arr[i].parentNode.removeChild(arr[i]);
//}
//}
});
});
</script>
</head>
<body>
<form>
<div>div1</div>
<div>div2</div>
<div>div3</div>
<div>div4</div>
</form>
<div>div5</div>
<input type="button" id="btn" value="删除" >
</body>
</html>
|