1.
1 <%@ page language="java" contentType="text/html; charset=UTF-8" 2 pageEncoding="UTF-8"%> 3 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 4 <html> 5 <head> 6 <meta http-equiv="Content-Type" content="text/html;charset=utf-8"> 7 <title>创建DOM节点</title> 8 <link rel="stylesheet" href="common.css" type="text/css" /> 9 <script src="jquery-1.5.2.js" type="text/javascript"></script> 10 <script type="text/javascript"> 11 $(document).ready( function() { 12 //append() - 在被选元素的结尾插入内容 13 $('p').append("<br /><b>Hello World!</b>") 14 //prepend() - 在被选元素的开头插入内容 15 $('h2').prepend("<i>Start Line<br /></i>") 16 $('i').clone().prependTo('p'); 17 }); 18 </script> 19 </head> 20 <body> 21 <h2> 22 This is h2 title text content! 23 </h2> 24 <p> 25 A paragraph of text! 26 </p> 27 </body> 28 </html>