复制代码代码如下:
<%@ 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>
<голова>
<base href = "<%= basepath%>">
<Title> My jsp 'createlement.jsp' Начальная страница </title>
<meta http-equiv = "pragma" content = "no-cache">
<meta http-equiv = "cache-control" content = "no-cache">
<meta http-equiv = "истекает" content = "0">
<meta http-equiv = "Keywords" content = "Keyword1, Keyword2, Keyword3">
<meta http-equiv = "description" content = "Это моя страница">
<script type = "text/javascript"
src = "<%= request.getContextPath ()%>/jQuery/jQuery-1.7.min.js"> </script>
<script type = "text/javascript">
$ (function () {
$ ("#но"). click (function () {
var para = document.createElement ("p");
var node = document.createTextNode ("这是新段落。");
para.appendchild (узел);
var element = document.getElementbyId ("div1");
element.appendchild (para);
})
})
</script>
</head>
<тело>
<div id = "div1">
<p id = "p1">
这是一个段落。
</p>
<p id = "p2">
这是另一个段落。
</p>
</div>
<input type = "button" id = "но" value = "添加">
</body>
</html>