tarun Posted May 20, 2007 Share Posted May 20, 2007 Say I Have A UL <ul name="list"> <li>Item 1</li> <li>Item 2</li> </ul> How Do I Add And Remove Items To And From It Using Javascript ANY Help Appreicated Thnx, Tarun Quote Link to comment Share on other sites More sharing options...
emehrkay Posted May 20, 2007 Share Posted May 20, 2007 remove child http://developer.mozilla.org/en/docs/DOM:element.removeChild append child http://developer.mozilla.org/en/docs/DOM:element.appendChild first child/last child http://developer.mozilla.org/en/docs/DOM:element.firstChild next sibling http://developer.mozilla.org/en/docs/DOM:element.nextSibling Quote Link to comment Share on other sites More sharing options...
tarun Posted May 21, 2007 Author Share Posted May 21, 2007 To Be Honest I Don't Understand Could You Provide An Example Please Cheers... Quote Link to comment Share on other sites More sharing options...
emehrkay Posted May 22, 2007 Share Posted May 22, 2007 taken from the examples (you need to give you list an id, in this example, it is "list"): to add one // Create a new paragraph element var list_item = document.createElement("li"); // Append it to the end of the document body document.getElementById('list").appendChild(list_item); to remove last list_item: document.getElementById("list").removeChild(document.getElementById('list').lastChild); Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.