Suppose I have an Unordered List in my HTML file:
[HTML]<html>
<head>
<SCRIPT LANGUAGE="JavaS cript">
function remove(){
//code to remove the old elements
var d=document.getE lementById("for um");
d.parentNode.re moveChild(d);
//code to add new elements
var li =document.creat eElement("li");
var p = document.create TextNode('Hello ');
li.appendChild( p);
d.insertBefore( li, 1); //this is not working
}
</SCRIPT>
</head>
.....
<ul id="forum">
<li>JavaScrip t</li>
<li>Forum</li>
</ul>
....
<input type="button" onclick="remove ()" >
</html>[/HTML]
Now, what is the code I have to write to remove to add new elements after removing all the parent elements?
Plz sort out my problem... Thanks in advance.
regards,
Ranjan Y
[HTML]<html>
<head>
<SCRIPT LANGUAGE="JavaS cript">
function remove(){
//code to remove the old elements
var d=document.getE lementById("for um");
d.parentNode.re moveChild(d);
//code to add new elements
var li =document.creat eElement("li");
var p = document.create TextNode('Hello ');
li.appendChild( p);
d.insertBefore( li, 1); //this is not working
}
</SCRIPT>
</head>
.....
<ul id="forum">
<li>JavaScrip t</li>
<li>Forum</li>
</ul>
....
<input type="button" onclick="remove ()" >
</html>[/HTML]
Now, what is the code I have to write to remove to add new elements after removing all the parent elements?
Plz sort out my problem... Thanks in advance.
regards,
Ranjan Y
Comment