首页 > 其他 > 详细

19.替换

时间:2018-02-23 15:27:14      阅读:190      评论:0      收藏:0      [点我收藏+]

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
-->

  

19.替换

原文:https://www.cnblogs.com/syj1993/p/8462022.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!