复制代码代码如下:
<%@ page idioma = "java" import = "java.util.*" PageEncoding = "UTF-8"%>
<%
String ruta = request.getContextPath ();
String basepath = request.getScheme () + ": //"
+ request.getServerName () + ":" + request.getServerPort ()
+ ruta + "/";
%>
<! Doctype html público "-// w3c // dtd html 4.01 transitional // en">
<html>
<Evista>
<base href = "<%= basepath%>">
<title> my jsp 'createElement.jsp' Página inicial </title>
<meta http-equiv = "pragma" content = "no-cache">
<meta http-oquiv = "cache-control" content = "no-cache">
<meta http-oquiv = "expires" content = "0">
<meta http-equiv = "Keywords" content = "Keyword1, Keyword2, Keyword3">
<meta http-oquiv = "descripción" content = "esta es mi página">
<script type = "text/javaScript"
src = "<%= request.getContextPath ()%>/jQuery/jQuery-1.7.min.js"> </script>
<script type = "text/javaScript">
$ (function () {
$ ("#pero"). Click (function () {
var para = document.createElement ("p");
var nodo = document.createTextNode ("这是新段落。");
para.appendchild (nodo);
var elemento = document.getElementById ("Div1");
elemento.appendChild (para);
})
})
</script>
</ablo>
<Body>
<div id = "div1">
<p id = "p1">
这是一个段落。
</p>
<p id = "p2">
这是另一个段落。
</p>
</div>
<input type = "button" id = "pero" valor = "添加">
</body>
</html>