But I get a javascript error on line2:
Object doesn't support this property or method.

Could anyone please tell how do I delete all the children and sub children of a tag in an Html document?

Thanks a lot!

03-19-2004, 05:25 PM

jkd

newRange = document.createRange();

03-19-2004, 06:16 PM

mamtakansal

I have tried using document.createRange() as well. In that case also, I get the same javascript error:

Object doesn't support this property or method.

Thanks!

03-19-2004, 06:25 PM

jkd

You're probably using Internet Explorer than. Their developers implemented a TextRange object, which they often call simply a Range. However, the W3C DOM working group also created a Range object in DOM2. IE's TextRange object is not compliant at all with the DOM2 Range specifications, even though you sometimes see similarly named methods (createRange() for instace). That is probably what is confusing you.

Try using document.createRange() and the rest of your code in Mozilla. It will work fine.

03-19-2004, 07:53 PM

mamtakansal

Thanks for your response! I have figured out a way of removing nested elements in an html tag in IE.

Regards,
Mamta.

03-19-2004, 09:15 PM

liorean

Well, if you just want to limit it to childrens of a certain element, it's easy. If you want it to be the elements contained in a selection it gets trickier. To remove from a single element and all it's children you simply do:

Code:

element.parentNode.removeChild(element);

05-18-2004, 10:59 PM

iceboxqs

Mamtakansal,

I was wondering . . .

Would you be willing to share how you got it working with IE?

:thumbsup:

05-20-2004, 09:54 PM

mamtakansal

Sure. I had variable number of rows with two fixed columns in the datatable. Here is what I did to remove the elements in the datatable: