Basic JavaScript Question:
Download Questions PDF

How to Add new elements dynamically?


<html xmlns="" xml:lang="en" lang="en">
<title>Title of page</title>
<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>

Download JavaScript Interview Questions And Answers PDF

Previous QuestionNext Question
To write messages to the screen without using "document.write()"? How to have an element invoke a JavaScript on selection, instead of going to a new URL?