function to remove all child nodes

by rajesh 2009-09-19 10:07:21

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>

Tagged in:

1459
like
0
dislike
0
mail
flag

You must LOGIN to add comments