Export (0) Print
Expand All
Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

createTextNode method

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);

Parameters

text [in, optional]

Type: String

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

Return value

Type: IHTMLDOMNode

Returns the created TextNode object.

Standards information

Examples


<!DOCTYPE html>

<html>
<head>
  <title>createTextNode</title>
</head>
<body>
  <span id="oSpan" onclick="fnChangeNode()">Original Text (click me)</span>
  <script>
    function fnChangeNode() {
      var oTextNode = document.createTextNode("New Text (thanks for the click)");
      var oReplaceNode = document.getElementById('oSpan').childNodes[0];
      oReplaceNode.replaceNode(oTextNode);
    }
  </script>
</body>
</html>

See also

document
Reference
createElement
Conceptual
About the W3C Document Object Model

 

 

Show:
© 2014 Microsoft