How to Add new elements dynamically in javascript ?

Bharathi Cherukuri
Posted by Bharathi Cherukuri under JavaScript category on | Points: 40 | Views : 1347
Here is an example to add new elements dynamically in javascript.


<html xmlns="" xml:lang="en" lang="en">
<script type="text/javascript">
function addNode() {
var newP = document.createElement("p");
var textNode = document.createTextNode(" I'm a new text node");

<body onload="addNode();" style=" background: url('../images/Sand-1280.jpg'); background-color: yellow;">

<p id="firstP">firstP<p>


Comments or Responses

Login to post response