5 out of 7 rated this helpful - Rate this topic

createTextNode method

[This documentation is preliminary and is subject to change.]

Creates a text string from the specified value.

Document Object Model (DOM) Level 3 Core Specification, Section 1.4

Syntax

var retval = document.createTextNode(text);

Standards information

Parameters

text [in, optional]

Type: BSTR

A String that specifies the nodeValue property of the text node.

Return value

Type: ObjectReturns the created TextNode object.

Remarks

This method always returns S_OK, so you must check the returned newTextNode value. If newTextNode is NULL, the method failed to create a new text node.

Examples


<SCRIPT>
function fnChangeNode(){
   var oTextNode = document.createTextNode("New Text");
   var oReplaceNode = oSpan.childNodes(0);
   oReplaceNode.replaceNode(oTextNode);
}
</SCRIPT>
<SPAN ID="oSpan" onclick="fnChangeNode()">
Original Text
</SPAN>

See also

document
Reference
createElement
Conceptual
About the W3C Document Object Model

 

 

Build date: 2/14/2012

Did you find this helpful?
(1500 characters remaining)
Community Content Add
Annotations FAQ