asp.net.ph

Skip Navigation Links

createTextNode Method

DHTML Methods


DOM Level 1 Specification.

Creates a text string from the specified value.

Syntax

oTextNode = document.createTextNode ( sText ) 
Parameters

sText Optional. String specifying the nodeValue of the text node.

Return Value

Returns a text node object.

Example

The following sample demonstrates use of the createTextNode method to create a text node and replace an existing text node in a heading object.

Click me.

<h4 id=oHead onclick="chgNode ( )">Click me.</h4>

<script language="JavaScript">
function chgNode ( ) {
newText = document.createTextNode ( "Hello, world." );
oldText = 
  document.getElementById ( 'oHead' ).childNodes [ 0 ] ;
oldText.nodevalue=newText.nodeValue;
}
</script>
Applies To

document

See Also

createElement



© 2025 Reynald Nuñez and asp.net.ph. All rights reserved.

If you have any question, comment or suggestion
about this site, please send us a note