<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>字串路徑= request.getContextPath(); <br>String basePath = request.getScheme() "://" <br> request.getServerName() ":" request.getServerPort() <br> 路徑"/"; <br>%> <br><br> <br> <br> <br><base href="<%=basePath%>"> <br> <br><title>我的JSP 'createElement.jsp' 起始頁</title> <br><br><meta http-equiv="pragma" content="no-cache"> <br><meta http 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="這是我的頁面"> <br><script type="text/javascript">src="<%= request.getContextPath()%>/jquery/jquery-1.7.min.js"></script> <br> <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>頭> <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><br> </div>