function to remove all child nodes - DOM Views : 503
Tagged in : DOM
0 0
Send mail
You can use the following javascript function to remove all children of a given parent node

function removeChildNodes(obj)
{
if(obj.hasChildNodes() && obj.childNodes) {
while(obj.firstChild) {
obj.removeChild(obj.firstChild);
}
}
}



so if you want to remove everything from the page, you can just call the javascript function as
<script language=javascript>
removeChildNodes(document.body);
</script>
By rajesh, On - 2009-09-19



    Login to add Comments .