<%@pagelanguage="java"import="java.util.*"pageEncoding="UTF-8"%>
<%
Stringpath=request.getContextPath();
StringbasePath=request.getScheme()+"://"
+request.getServerName()+":"+request.getServerPort()
+path+"/";
%>
<!DOCTYPEHTMLPUBLIC"-//W3C//DTDHTML4.01Transitional//EN">
<html>
<head>
<basehref="<%=basePath%>">
<title>MyJSP'createElement.jsp'startingpage</title>
<metahttp-equiv="pragma"content="no-cache">
<metahttp-equiv="cache-control"content="no-cache">
<metahttp-equiv="expires"content="0">
<metahttp-equiv="keywords"content="keyword1,keyword2,keyword3">
<metahttp-equiv="description"content="Thisismypage">
<scripttype="text/javascript"
src="<%=request.getContextPath()%>/jquery/jquery-1.7.min.js"></script>
<scripttype="text/javascript">
$(function(){
$("#but").click(function(){
varpara=document.createElement("p");
varnode=document.createTextNode("这是新段落。");
para.appendChild(node);
varelement=document.getElementById("div1");
element.appendChild(para);
})
})
</script>
</head>
<body>
<divid="div1">
<pid="p1">
这是一个段落。
</p>
<pid="p2">
这是另一个段落。
</p>
</div>
<inputtype="button"id="but"value="添加">
</body>
</html>