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:
var textNode = document.createTextNode('Example text...');
Practical example
In this example, we use document.createTextNode()
to create a text node dynamically and then append it to the document.body
.
// ONLINE-RUNNER:browser;
<!doctype html>
<html>
<body>
<script>
var textNode = document.createTextNode('Example text...');
document.body.appendChild(textNode);
</script>
</body>
</html>