复制代码代码如下:
<%@ページ言語= "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>私のjsp 'createElement.jsp'開始ページ</title>
<メタhttp-equiv = "pragma" content = "no-cache">
<Meta http-equiv = "cache-control" content = "no-cache">
<メタhttp-equiv = "expires" content = "0">
<meta http-equiv = "keywords" content = "keyword2、keyword3">
<メタhttp-equiv = "description" content = "これは私のページ">
<script type = "text/javascript"
src = "<%= request.getContextPath()%>/jQuery/jQuery-1.7.min.js"> </script>
<script type = "text/javascript">
$(function(){
$( "#but")。クリック(function(){
var para = document.createelement( "p");
var node = document.createTextNode( "这是新段落。");
Para.AppendChild(ノード);
var element = document.getElementById( "div1");
Element.AppendChild(PARA);
})
})
</script>
</head>
<body>
<div id = "div1">
<p id = "p1">
这是一个段落。
</p>
<p id = "p2">
这是另一个段落。
</p>
</div>
<入力型= "button" id = "しかし" value = "添加">
</body>
</html>