Forum Moderators: open
----------------
<body>
<div id="toberemoved">
<a href="[somelink]">Remove DIV</a>
<iframe src="[somepage]">
</iframe>
</div>
...
----------------
If I want to remove the div "toberemoved" from the page, along with all of its children, what should I do with removeChild to remove it? Will this code work (It does nothing when I try to run it)?
function destroydiv() {
var d = document.getElementById("body");
var d_nested = document.getElementById("toberemoved");
var destroyed = d.removeChild(d_nested);
}
Thanks for all the trouble.
try it like this...
<script type="text/javascript">
<!--
function getRidOf(){
document.body.removeChild(document.body.firstChild);
}
//-->
</script>
<body><div id="toberemoved">
<a href="#" onclick=" getRidOf()">Remove DIV</a>
<iframe src="#">
</iframe>
</div>
birdbrain