textNode object (Object/DOM)

A string of text represented as a node within the document hierarchy.


DOM level - 1
JavaScript - 1.5
JScript - 5.0
Internet Explorer - 5.0
Netscape - 6.0
Inherits from:CharacterData object
JavaScript syntax:IEmyTextNode = myDocument.all.tags("TEXT")[anIndex]
-myTextNode = myDocument.createTextNode(someData)
Argument list:someDataTextual content for the text node
anIndexA selector within a collection of text nodes
Object properties:data, length
Object methods:splitText()

The MSIE browser models the document as a collection of nodes. Clearly, an HTML tag corresponds to an object. However, what isn't so obvious is that the text in between HTML tags is collected together and represented by a textNode object.

These textNodes are generally accessible as child objects belonging to an object instantiated by an HTML tag.

For example:


can be accessed as follows:

The <P> tags are objects which are members of the document.getElementsByTagName("P") collection. The text "BBB" is referenced through the firstChild property of the P object instantiated by the first <P> tag. The text "CCC" is a textNode object referenced via the firstChild property of the second <P> tag.

The DOM level 3 specification is expected to add the following method to the textNode object:

See also:Attribute.nodeName, Document.createTextNode()

data1.5 1.55.0 5.06.0 6.05.0 5.0 n/a n/a n/a1 1 n/a n/a-
length1.5 1.55.0 5.06.0 6.05.0 5.0 n/a n/a n/a1 1 n/a n/aReadOnly.

splitText()1.5 1.55.0 5.06.0 6.05.0 5.0 n/a n/a n/a1 1 n/a n/a-

Inheritance chain:

CharacterData object, Node object