<!doctype html>
<html lang="en">
<head>
<title>create text node example</title>
<script>
function addtextnode(text){
var newtext = document.createTextNode(text),
p1 = document.getElementById("p1");
p1.appendChild(newtext)
;
}
</script>
</head>
<body>
<button onclick="addTextNode('YES!');">yes</button>
<button onclick="addTextNode('NO!');">no</button>
<button onclick="addTextNode('WE CAN!);">we can</button>
<hr />
<p id="p1">first line of paragraph</p>
</body>
</html>
var text = document.createTextNode(data);
Be the first to comment
You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.