<div class="codetitle"> <span><a style="CURSOR: pointer" data="89298" class="copybut" id="copybut89298" onclick="doCopy('code89298')"><u>复制代码</u></a></span> 代码如下:</div> <div class="codebody" id="code89298"> <br> <br>String path = request.getContextPath(); <br>String basePath = request.getScheme() + "://" <br>+ request.getServerName() + ":" + request.getServerPort() <br>+ path + "/"; <br>%> <br><br> <br> <br> <br><base href="<%=basePath%>"> <br><br><title>My JSP 'createElement.jsp' starting page</title> <br><br><meta http-equiv="pragma" content="no-cache"> <br><meta http-equiv="cache-control" content="no-cache"> <br><meta http-equiv="expires" content="0"> <br><meta http-equiv="keywords" content="keyword1,keyword2,keyword3"> <br><meta http-equiv="description" content="This is my page"> <br><script type="text/javascript">src="<%=request.getContextPath()%>/jquery/jquery-1.7.min.js"></script> <br><script type="text/javascript"> <BR>$(function() { <BR>$("#but").click(function() { <BR>var para = document.createElement("p"); <BR>var node = document.createTextNode("这是新段落。"); <BR>para.appendChild(node); <br><br>var element = document.getElementById("div1"); <BR>element.appendChild(para); <br><br>}) <BR>}) <BR></script> <br> <br> <br><div id="div1"> <br><p id="p1"> <br>这是一个段落。 <br></p> <br><p id="p2"> <br>这是另一个段落。 <br></p> <br> </div> <br><input type="button" id="but" value="添加"> <br> <br> <br> </div>