Changing childNode text.

Posted on 2003-10-24
Last Modified: 2008-02-01
<p id="n1">AAAAAA<em>BBBBBB</em>CCCCCC<em>DDDDDD</em>EEEEEE</p>

I have the above


gives me 5 as I would expect


changes AAAAA to XXXXX as I would expect, as does using firstChild



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?

Question by:Xxavier
LVL 25

Accepted Solution

devic earned 125 total points
ID: 9619342
LVL 12

Expert Comment

ID: 9619389
And that is correct behaviour under DOM rules. Element has nodeValue of NULL.

Author Comment

ID: 9619540
Thanks that makes sense now.

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In Part 1 ( we covered the hexagonal maze basics -- how the cells are represented in a JavaScript array and how the maze is displayed.  In this part, we'…
JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now