/ Published in: JavaScript
small and simple logic for all dotnet, php, java and other web developers, useful for your dynamic processing.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
<!--useful snippet for changing the list items and addmore to the existing items,useful for all php,dotnet,java and other web developers--> <!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=iso-8859-1" /> <title>Manipulate List Items</title> <script type="text/javascript"> function init(){ first = document.getElementById("group1"); last = document.getElementById("group2"); } function ADD(){ var li = document.createElement("li"); var liText = document.createTextNode("sample add"); li.appendChild(liText); first.appendChild(li); } function REP(){ first.parentNode.replaceChild(last,first); first = last; } </script> </head> <body onload="init()"> <div onclick="ADD()">Add</div> <div onclick="REP()">Mask</div> <ol id="group1"> <li>List Item</li> <li>List Item</li> <li>List Item</li> <li>List Item</li> </ol> <ul id="group2"> <li>List Item</li> <li>List Item</li> <li>List Item</li> <li>List Item</li> </ul> </body> </html>