EN
JavaScript - create text node dynamically
0 points
In this article, we would like to show you how to create text node dynamically using JavaScript.
Quick solution:
xxxxxxxxxx
1
var textNode = document.createTextNode('Example text...');
In this example, we use document.createTextNode()
to create a text node dynamically and then append it to the document.body
.
xxxxxxxxxx
1
2
<html>
3
<body>
4
<script>
5
6
var textNode = document.createTextNode('Example text...');
7
document.body.appendChild(textNode);
8
9
</script>
10
</body>
11
</html>