...

View Full Version : Removing All Child Nodes From Parent



windy
02-10-2007, 08:00 AM
Hi,

I'm using the following code to remove all child nodes from a parent. I guess it's another example that breaks IE(7). Can someone suggest an IE-tolerant alternative.

Thanks, windy




var strID = 'parentNodeName';
var parent = document.getElementById(strID);
removeChildNodes(parent);

function removeChildNodes(parent){
while(parent.hasChildNodes()){
parent.removeChild(parent.childNodes[0]) //--> IE error 'Not found'
}
}

BubikolRamios
02-10-2007, 08:11 AM
this is what I have somewhere, didn't test it for your error. Try it.


// remoove all inner elements of TDnodeObj
while(TDnodeObj.firstChild) TDnodeObj.removeChild(TDnodeObj.firstChild);

Regards

windy
02-10-2007, 04:23 PM
Thanks, that seems to work

w



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum