I am looking for some sample JavaScript code that will allow me to have a list of N items and to be able to toggle that list between a collapsed top item and an expan开发者_开发知识库ded list of all of the items.
Anyone have any ideas?
I think you're looking for something like Treeview
You probably want to use a a function like:
function toggle(itemsInList) {
for (var i = 0; i < itemsInList.length; ++i) {
itemsInList[i].style.display = (itemsInList[i].style.display == "block") ? "none" : "block";
}
}
精彩评论