Xxavier
asked on
Changing childNode text.
<p id="n1">AAAAAA<em>BBBBBB</ em>CCCCCC< em>DDDDDD< /em>EEEEEE </p>
I have the above
alert(document.getElementB yId("n1"). childNodes .length)
gives me 5 as I would expect
document.getElementById("n 1").childN odes[0].no deValue="X XXXXX"
changes AAAAA to XXXXX as I would expect, as does using firstChild
but
document.getElementById("n 1").childN odes[1].no deValue="X XXXXX"
does nothing and printing out the nodeValue gives NULL. I am a bit rusty with this stuff and am trying to access the 2nd node with value BBBB, or I am up a conceptual gum tree here? ie change BBBBB to XXXX. I know I can give it an id and access it that way but can I access as a childnode of n1?
I have the above
alert(document.getElementB
gives me 5 as I would expect
document.getElementById("n
changes AAAAA to XXXXX as I would expect, as does using firstChild
but
document.getElementById("n
does nothing and printing out the nodeValue gives NULL. I am a bit rusty with this stuff and am trying to access the 2nd node with value BBBB, or I am up a conceptual gum tree here? ie change BBBBB to XXXX. I know I can give it an id and access it that way but can I access as a childnode of n1?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
And that is correct behaviour under DOM rules. Element has nodeValue of NULL.
ASKER
Thanks that makes sense now.