replaceWith(): a.replaceWith(c) 用a替换c
replaceAll(): a.replaceAll(c) 用a替换所有的c
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>05_替换节点.html</title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<script type="text/javascript" src="./js/jquery-1.8.3.js"></script>
<script type="text/javascript">
$(document).ready(function(){
//1.用"<span>许木木</span>"替换id为span1的span
$("#span1").replaceWith("徐木木");
//2.用a标签替换全部class为span2的span
$("<a href=‘#‘>xumumu</a>").replaceAll($(".span2"));
});
</script>
</head>
<html>
<p>姓名:<span id="span1"></span></p>
<p>邮箱1:<span class="span2"></span></p>
<p>邮箱2:<span class="span2"></span></p>
</html>
<script type="text/javascript">
</script>
</html>
<!--
replaceWith(content|fn) a.replaceWith(c); 用c替换a
replaceAll(selector) a.replaceAll(c): 用a替换所有的c
-->