function addNode() { var newP = document.createElement("p"); v..." /> Write The Code For Adding New Elements Dynamically? function addNode() { var newP = document.createElement("p"); v..." /> function addNode() { var newP = document.createElement("p"); v..." />
Answers

Question and Answer:

  Home  Expert JavaScript Developer

⟩ Write the code for adding new elements dynamically?

<html>

<head> <title>t1</title>

<script type="text/javascript">

function addNode() { var newP = document.createElement("p");

var textNode = document.createTextNode(" This is a new text node");

newP.appendChild(textNode); document.getElementById("firstP").appendChild(newP); }

</script> </head>

<body> <p id="firstP">firstP<p> </body>

</html>

 178 views

More Questions for you: