<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<script type="text/javascript" src="js/jquery-1.8.3.js" ></script>
</head>
<body>
<!--内部插入-->
<div id="univerdity">
<span>郑州</span>
</div>
<script>
$("#univerdity").prepend("<i>大学</i>");/*向每个匹配元素内部的开始处插入内容*/
$("#univerdity").append("<b>大学</b>");/*向每个匹配元素内部的末尾处插入内容*/
</script>
<!--外部插入-->
<p>henan</p>
<script>
$("p").before("<i>zhongguo</i>");/*向每个匹配的元素前插入内容*/
$("p").after("<i>大学</i>");/*向每个匹配的元素后插入内容*/
$("p").after("<a href='http://www.baidu.com'>baidu</a>");
</script>
<!--包裹-->
<img src="img/2.jpg"/>
<script>
$("img").wrap("<a href='http://www.sina.com.cn'></a>");/*把所有匹配的元素用其他元素的结构化标记包裹起来*/
</script>
</body>
</html>
内部插入效果:
外部插入效果:
包裹效果: