0 votes
163 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 126 views
+1 vote
1 answer 100 views
0 votes
1 answer 59 views
+1 vote
1 answer 703 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

537 users

...