HTML | DOM createTextNode() Method
The createTextNode() method is used to create a TextNode which contains element node and a text node. It is used to provide text to an element. This method contains the text values as parameter which is of string type.
Syntax:
document.createTextNode( text )
Parameters: This method accepts single parameter text which is mandatory. It is used to specify the text of text node.
Example:
<!DOCTYPE html> <html> <head> <title>DOM createTextNode() Method</title> <style> h1, h2 { color:green; font-weight:bold; } body { text-align:center; } </style> </head> <body> <h1>GeeksForGeels</h1> <h2>DOM createTextNode() Method</h2> <button onclick="geeks()">Submit</button> <script> function geeks() { var x = document.createTextNode("GeeksForGeeks"); document.body.appendChild(x); } </script> </body> </html> |
Output:

Supported Browsers: The browser supported by DOM createTextNode() Method property are listed below:
- Google Chrome
- Internet Explorer
- Firefox
- Opera
- Safari
Recommended Posts:
- PHP | DOMDocument createTextNode() Function
- HTML | DOM contains() Method
- HTML | DOM isDefaultNamespace() Method
- HTML | DOM isSameNode() Method
- HTML | DOM click() Method
- HTML | DOM querySelectorAll() Method
- HTML | DOM querySelector() Method
- HTML | DOM getAttributeNode() Method
- HTML | DOM exitFullscreen() Method
- HTML | DOM hasChildNodes() Method
- HTML | DOM normalizeDocument() Method
- HTML | DOM importNode() Method
- HTML | DOM isEqualNode() Method
- HTML | DOM removeAttributeNode() Method
- HTML | DOM cloneNode() Method
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.



