Availability: |
| ||||||
Inherits from: | CharacterData object | ||||||
JavaScript syntax: | IE | myTextNode = myDocument.all.tags("TEXT")[anIndex] | |||||
- | myTextNode = myDocument.createTextNode(someData) | ||||||
Argument list: | someData | Textual content for the text node | |||||
anIndex | A 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:
AAA<P>BBB<P>CCC
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:
isWhitespaceInElementContent()
See also: | Attribute.nodeName, Document.createTextNode() |
Property | JavaScript | JScript | N | IE | Opera | NES | ECMA | DOM | CSS | HTML | Notes |
---|---|---|---|---|---|---|---|---|---|---|---|
data | 1.5 ![]() | 5.0 ![]() | 6.0 ![]() | 5.0 ![]() | ![]() | ![]() | ![]() | 1 ![]() | ![]() | ![]() | - |
length | 1.5 ![]() | 5.0 ![]() | 6.0 ![]() | 5.0 ![]() | ![]() | ![]() | ![]() | 1 ![]() | ![]() | ![]() | ReadOnly. |
Method | JavaScript | JScript | N | IE | Opera | NES | ECMA | DOM | CSS | HTML | Notes |
---|---|---|---|---|---|---|---|---|---|---|---|
splitText() | 1.5 ![]() | 5.0 ![]() | 6.0 ![]() | 5.0 ![]() | ![]() | ![]() | ![]() | 1 ![]() | ![]() | ![]() | - |
Prev | Home | Next |
TextCell.value | Up | textNode.data |
JavaScript Programmer's Reference, Cliff Wootton Wrox Press (www.wrox.com) Join the Wrox JavaScript forum at p2p.wrox.com Please report problems to support@wrox.com © 2001 Wrox Press. All Rights Reserved. Terms and conditions. |