If you click "+", "add a list entry example dynamically", if you click "-", add a list entry example dynamically, and then delete one
<! Doctype HTML public "-// W3C // dtd xhtml 1.0 transitional // en" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<HTML xmlns = "http://www.w3.org/1999/xhtml">
<Head>
<Meta http-equiv = "Content-Type" content = "text/html; charset = gb2312"/>
<Title> Create unordered list entries dynamically in Javascript </title>
</Head>
<Body>
<Ul id = "news">
<Li> example of dynamically adding list entries </LI>
<Li> example of dynamically adding list entries </LI>
</Ul>
<Input type = "button" id = "btnadd" value = "+"/>
<Input type = "button" id = "btndel" value = "-"/>
<SCRIPT type = "text/JavaScript">
VaR onew = Document. getelementbyid ("news ");
Document. getelementbyid ("btnadd"). onclick = function (){
Oelentment = Document. createelement ("Li ");
Otextnode = Document. createtextnode ("example of dynamically adding list entries ");
Oelentment. appendchild (otextnode );
Onew. appendchild (oelentment );
}
Document. getelementbyid ("btndel"). onclick = function (){
If (onew. haschildnodes ()){
Onew. removechild (onew. lastchild );
}
}
</SCRIPT>
</Body>
</Html>