0 votes
185 views
in Javascript by (98.9k points)
edited

Write the code for adding new elements dynamically?

1 Answer

0 votes
by (98.9k points)
selected by
 
Best answer
<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>

Related questions

0 votes
1 answer 145 views
+1 vote
1 answer 127 views
0 votes
1 answer 88 views
+1 vote
1 answer 747 views

Doubtly is an online community for engineering students, offering:

  • Free viva questions PDFs
  • Previous year question papers (PYQs)
  • Academic doubt solutions
  • Expert-guided solutions

Get the pro version for free by logging in!

5.7k questions

5.1k answers

108 comments

561 users

...