How to use DOM Object CreateTextNode in JavaScript
In this article I am going to explain about DOM object CreateTextNode() method in JavaScript
JavaScript DOM Object CreateTextNode() Method
JavaScript CreateTextnode() method use for create a new text node with specified given text.
Syntax
var ss=Document.CreateTextNode("Your Message")
|
Example // In this example when you will click on button then a new text node will be created.
<html>
<head>
<script type="text/javascript">
function myfun() {
var mm = document.createElement("H2");
var tt = document.createTextNode("Hello Friends");
mm.appendChild(tt);
document.body.appendChild(mm);
};
</script>
</head>
<body>
<p>
click button for create text node</p>
<button onclick="myfun()">
click me</button>
</body>
</html>
|
Output
Before Click button
After click button
You may also want to read these related articles: here
Ask Your Question
Got a programming related question? You may want to post your question here