复制代码代码如下 :
<%@ page language = "java"import = "java.util.*"pageencoding = "utf-8"%>
<%
문자열 path = request.getContextPath ();
문자열 basepath = request.getScheme () + ": //"
+ request.getServerName () + ":" + request.getServerport ()
+ Path + "/";
%>
<! doctype html public "-// w3c // dtd html 4.01 Transitional // en">
<html>
<헤드>
<base href = "<%= basepath%>">
<title> 내 jsp 'createElement.jsp'시작 페이지 </title>
<meta http-equiv = "pragma"content = "no-cache">
<meta http-equiv = "캐시 제어"content = "no-cache">
<meta http-equiv = "만료"내용 = "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 () {
$ ( "#하지만"). 클릭 (function () {
var para = document.createElement ( "p");
var node = document.creatextNode ( "这是新段落。");
para. AppendChild (노드);
var 요소 = document.getElementById ( "div1");
요소. AppendChild (para);
})
})
</스크립트>
</head>
<body>
<div id = "div1">
<p id = "p1">
这是一个段落。
</p>
<p id = "p2">
这是另一个段落。
</p>
</div>
<입력 유형 = "button"id = "그러나"value = "添加">
</body>
</html>