OZONE Asylum
Forums
XML - XSL - XSLT - XHTML - CSS - DOM
[DOM] Removing nodes.
This page's ID:
10787
Search
QuickChanges
Forums
FAQ
Archives
Register
Edit Post
Who can edit a post?
The poster and administrators may edit a post. The poster can only edit it for a short while after the initial post.
Your User Name:
Your Password:
Login Options:
Remember Me On This Computer
Your Text:
Insert Slimies »
Insert UBB Code »
Close
Last Tag
|
All Tags
UBB Help
Ok, here I face another problem. Here I have a standard compliant document with that part: [code] <table id="bag"> <tr> <td>Knife</td> <td>0.2</td> </tr> <tr> <td>rope</td> <td>2</td> </tr> </table> [/code] Fact is that I want to remove those 2 lines from the table and add some others. Here is the code I use: <edit> getObj method is a convenient method to replace getElementById... :p </edit> [code] var tree = getObj('bag'); var arr = tree.getElementsByTagName("tr"); for(i=0; i<arr.length; i++) { alert("Removing node " + arr[i].nodeName); getObj('bag').removeChild(arr[i]); } [/code] The alert message is ok: it tell me that i am removing a TR node. BUT! The next line throw an exception "Node not found" (peeked into Mozilla javascript window, those shitty ie just say "error" without further explanation) I don't understand... Trying another approach, I changed the problematic line with this one: [code] getObj('bag').removeChild(getObj('bag').firstChild); [/code] THIS TIME, the function works perfectly under Mozilla 1.1, removes line by line and let me add other lines after; but behaves strangely in ie: the first call remove all the TR in one strike! Did I missed something???? Any DOM expert around here? :) Thanks!!!!!!!!! [This message has been edited by OMERA (edited 08-11-2002).]
Loading...
Options:
Enable Slimies
Enable Linkwords
« Backwards
—
Onwards »