WebFX WebBoard
Message Thread:
View All Messages
Back to WebFX
 [ DOM ] node type, dreadcast, September 3, 2003
     Re:[ DOM ] node type, Chris, September 3, 2003
         Re:[ DOM ] node type, dreadcast, September 4, 2003
             Re:[ DOM ] node type, Erik Arvidsson, September 5, 2003

Subject: Re:[ DOM ] node type From: Chris Date: September 3, 2003
Moz returns 'undefined' because the first childNode in

<div id="select1">
<div id="db1">tata</div>
<div id="db2">toto</div>
<div id="db3">titi</div>
.....
</div>

is a text node since there is a new line between
<div id="select1">

and
<div id="db1">tata</div>

This is the 'correct' way of interpreting childNodes (see info on XML for more of an explanation).

So if childNodes[0] is a text node, it isnt going to have an id attribute...

use childNode[1] for Moz to get the HTMLDivElement you want and so get its id.

(this is also true for childNodes[2] etc... you need to go for the odd numbers to get all your DIV's...)

To keep the same code for referencing them, you could structure the divs like:

<div id="select1"><div id="db1">tata</div><div id="db2">toto</div><div id="db3">titi</div>.....</div>

so there's no white space between them...

Chris



Reply
Name: 
Email: 
Subject: 

Enter your reply to this message below. HTML tags are not supported but words that start with http://, ftp:// or mailto: are converted to links.


View All Messages
Back to WebFX