Question about #text

T

Tom Cole

Let's say I have the following:

<div id="master">
This is master part 1
<div id="slave">
This is slave
</div>
This is master part 2
</div>

I can call document.getElementById('master').childNodes.length and get
3.

My question is this: how can I determine that childNodes[0] is a #text
node and how can I change it without affecting the rest (i.e. the
slave div node and the second #text node).

Thanks.
 
M

Marc

Tom Cole said:
Let's say I have the following:

<div id="master">
This is master part 1
<div id="slave">
This is slave
</div>
This is master part 2
</div>

I can call document.getElementById('master').childNodes.length and get
3.

My question is this: how can I determine that childNodes[0] is a #text
node and how can I change it without affecting the rest (i.e. the
slave div node and the second #text node).

Thanks.

uhm... something like:

var obj = document.getElementById('master');
var test = 0;
for(var i=0;i<obj.childNodes.length; i++){
if (obj.childNodes.nodeName != "#text"){
test++
}
}
alert("actual html tag count: " +test);
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,780
Messages
2,569,611
Members
45,265
Latest member
TodLarocca

Latest Threads

Top