Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

document.getElementsByTagName

Status
Not open for further replies.

robert89

Technical User
Nov 19, 2003
125
CA
I have a piece of script which produces an "exploding menu". The menu is constructed from lists. There is a body onload command which causes all the menus to open in the collapsed position. The user clicks on a heading and the list expands.

The function that hides everything on load Gets the Element by Tag Name. In this case it is the ul. Unfortunately, I have other uls and if I use <!-- <body onload="hideall()"> all menu lists disappear. The function is:
function hideall() {
var Nodes = document.getElementsByTagName('ul')
var max = Nodes.length
for(var i = 0;i < max;i++) {
var nodeObj = Nodes.item(i)
nodeObj.style.display = 'none';
}
}

How can I get this to only collapse the lists that are held within a <div id="menu">

Help would be greatly appreciated.

Thanks,
Bob
 
It is then this.
[tt] //var Nodes = document.getElementsByTagName('ul')
var Nodes = document.getElementById("menu").getElementsByTagName("ul")
[/tt]
 
Hi Tsuji,
Thank you very much. I was playing with the idea you introduced but wasn't parenting/childing correctly. This is terrific. Thank you, thank you, thank you.

Bob
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top