Please login to start chat

ICT Solutions 24 Jun 2022, 12:08:17
Category : JavaScript Tutorials

appendChild() (HTML DOM Elements)

<!DOCTYPE html>
<html>
<head>
<title>JS Code Testing</title>
</head>
<body>
<ul id = "myText">
<li>Thet</li>
<li>Naing</li>
</ul>

<button onclick = "jsFun()">Try It</button>

<script>
function jsFun(){
var node = document.createElement("LI");
var txtNode = document.createTextNode("Win");
node.appendChild(txtNode);
document.getElementById("myText").appendChild(node);
}
</script>
</body>
</html>

Comments:

No comment to show.

Available Services
Download Android Application