Home > Javascript > Delete a tag in Javascript

Delete a tag in Javascript

October 9th, 2008

I use with with AJAX library to completely remove a DIV tag ( or whatever )


function removeTag(tag){
field = document.getElementById(tag);
field.parentNode.removeChild(field);
}

function removeAllChildren(field){
if ( field.hasChildNodes() )
{
while ( field.childNodes.length >= 1 )
{
removeAllChildren(field.firstChild);
field.removeChild(field.firstChild);
}
}
}

[Slashdot] [Digg] [Reddit] [del.icio.us] [Facebook] [Google] [StumbleUpon]

Javascript

  1. No comments yet.
  1. No trackbacks yet.