...

View Full Version : REALLY SIMPLE - return the node's text



brookey86
04-29-2008, 08:45 PM
<label for="_QsT_283$1_8">Don't know</label>


I have the HTML above in a page and I'm trying to figure out how to return the text "Don't know". I have the correct object node for the <label> tag, and I've tried using:

node.nodeValue;
node.Text;

and that returns null and undefined, respectively. What can I do to get that text from between the tags?

flynch01
04-29-2008, 09:02 PM
Possible node.innerHTML

mrhoo
04-29-2008, 09:42 PM
<label for="_QsT_283$1_8">Don't know</label>
The element node contains a childNode, which is the actual container of the text.
If node refers to the label element you could use

node.firstChild.nodeValue or
node.childNodes[0].data



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum