DHTML Methods
DOM Level 1 Specification.
Creates a text string from the specified value.
oTextNode = document.createTextNode ( sText )
sText |
Optional. String specifying the nodeValue of the text node. |
Returns a text node object.
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>
document
createElement