TextNode object
Represents a string of text as a node in the document hierarchy.
Members
The TextNode object has these types of members:
Methods
The TextNode object has these methods.
| Method | Description |
|---|---|
| addEventListener |
Registers an event handler for the specified event type. |
| appendData |
Adds a new character string to the end of the object. |
| compareDocumentPosition |
Compares the position of two nodes in a document. |
| deleteData |
Removes a specified range of characters from the object. |
| dispatchEvent |
Sends an event to the current element. |
| insertData |
Inserts a new character string in the object at a specified offset. |
| isDefaultNamespace |
Indicates whether or not a namespace is the default namespace for a document. |
| isEqualNode |
Determines if two nodes are equal. |
| isSameNode |
Determines if two node references refer to the same node. |
| isSupported |
Returns a value indicating whether or not the object supports a specific DOM standard. |
| lookupNamespaceURI |
Gets the URI of the namespace associated with a namespace prefix, if any. |
| lookupPrefix |
Gets the namespace prefix associated with a URI, if any. |
| normalize |
Merges adjacent DOM objects to produce a normalized document object model. |
| removeEventListener |
Removes an event handler that the addEventListener method registered. |
| replaceData |
Replaces a specified range of characters in the object with a new character string. |
| replaceWholeText |
Replaces the text of the current object. |
| splitText |
Divides a text node at the specified index. |
| substringData |
Extracts a range of characters from the object. |
Properties
The TextNode object has these properties.
| Property | Description |
|---|---|
|
Returns a reference to the constructor of an object. | |
|
Sets or gets the value of a TextNode object. | |
|
Gets the number of characters in a TextNode object. | |
|
Retrieves the local name of the fully qualified XML declaration for a node. | |
|
Retrieves the namespace URI of the fully qualified XML declaration for a node. | |
|
Retrieves a reference to the next child of the parent for the object. | |
|
Gets the name of a particular type of node. | |
|
Retrieves the type of the requested node. | |
|
Gets or sets the value of a node. | |
|
Retrieves the parent object in the document hierarchy. | |
|
Retrieves the local name of the fully qualified XML declaration for a node. | |
|
Gets a reference to the previous child of the parent for the object. | |
|
Sets or retrieves the text content of an object and any child objects. | |
|
Retrieves the text of the current object. |
Remarks
Use the createTextNode method to create a TextNode object. After you create the TextNode, you can add to it using the appendChild, replaceNode, or insertBefore methods.
This object is available in script as of Microsoft Internet Explorer 5.
Examples
This example uses the TextNode object to change the text of an li object.
<script> function fnChangeText(){ var oTextNode = document.createTextNode("New List Item 1"); var oReplaceNode = oItem1.firstChild.replaceNode(oTextNode); } </script> <ul onclick = "fnChangeText()"> <li id = "oItem1">List Item 1</li> </ul>