L
Louis
Please help.....
I am starting to learn using javascript on DOM. One of the first things
I tested was listing all the child nodes from an element. Like ->
*html code:
<div id="pagetitle">
<span>My Text</span>
</div>
In my javascript I tried to list all the child nodes from <div>, Firefox
and Opera gave me 3 -- 1)text node with a null value, 2)span, 3)text
node with a null value.
It look to me that the browsers treated the line break as a text node
with no value!!
If I modified the html code to :
<div id="pagetitle"><span>My Text</span></div>
Then the browsers gave me the right answer: 1
They still gave me a wrong answer of 3 if I put a space around the
<span> element like this:
<div id="pagetitle"> <span>My Text</span> </div>
What did I do wrong? I would still want the elements to be on their own
lines.
Thank you.
I am starting to learn using javascript on DOM. One of the first things
I tested was listing all the child nodes from an element. Like ->
*html code:
<div id="pagetitle">
<span>My Text</span>
</div>
In my javascript I tried to list all the child nodes from <div>, Firefox
and Opera gave me 3 -- 1)text node with a null value, 2)span, 3)text
node with a null value.
It look to me that the browsers treated the line break as a text node
with no value!!
If I modified the html code to :
<div id="pagetitle"><span>My Text</span></div>
Then the browsers gave me the right answer: 1
They still gave me a wrong answer of 3 if I put a space around the
<span> element like this:
<div id="pagetitle"> <span>My Text</span> </div>
What did I do wrong? I would still want the elements to be on their own
lines.
Thank you.