js replaceChild

时间:2014-05-09 04:27:20   收藏:0   阅读:324
bubuko.com,布布扣
//父亲元素.replaceChild(新,旧)

1
<ul id="city"> 2 <li id="bj">北京</li> 3 <li id="sh">上海</li> 4 <li id="gz">广州</li> 5 </ul> 6 7 <ul id="color"> 8 <li id="red">红色</li> 9 <li id="green">绿色</li> 10 <li id="blue">蓝色</li> 11 </ul> 12 <script type="text/javascript"> 13 var gzLiElement=document.getElementById("gz"); 14 gzLiElement.onclick=function(){ 15 var colorElement=document.getElementById("color"); 16 //父亲元素.replaceChild(新,旧) 17 document.getElementById("city").replaceChild(colorElement,this); 18 alert("xx"); 19 }
bubuko.com,布布扣

 

js replaceChild,布布扣,bubuko.com

评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!