日期:2014-05-16  浏览次数:20368 次

js DOM操作进行div中所有对象的复制

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> js DOM操作进行div中所有对象的复制 </TITLE>
<script>
function show(){
var obj2=document.getElementById("LandLayer_SavedSearch_Delete2");
var obj3=document.getElementById("LandLayer_SavedSearch_Delete3");
iteraterTag(obj2,obj3);
alert(obj3.innerHTML);
}
function iteraterTag(obj2,targetObj){
var obj2_childs = obj2.childNodes;
while(obj2_childs.length) {
targetObj.appendChild(obj2_childs[0]);
}
}
</script>
</HEAD>

<BODY>
<div id="LandLayer_SavedSearch_Delete2" style="display:block;background-color:#FFF000;">
<div>You can set a new preferred Saved Search.</div>
<div>Search Name:
<select name="testSel" id="testSel">
<OPTION>123</OPTION>
<OPTION>234</OPTION>
</select>
</div>
<input type="button" onClick="childOK();" value="OK"/>
</div>
<div id="LandLayer_SavedSearch_Delete3" style="display:block;">
</div>
<div id="buttonLayer">
<input type="button" id="button_parent_saveas" name="button_parent_saveas" value="test" onClick="show();" /></br>
</div>
</BODY>
</HTML>