A
Angelos
Hello there.. I have the folowing piece of javascript that hides all my ul
elements in a menu of the folowing structure:
<ul>
<li><a href="#">Page</a>
<ul>
<li><a href="#">Add</a></li>
<li><a href="#">List</a></li>
</ul>
</li>
<li><a href="#" >News</a>
<ul>
<li><a href="#">Add</a></li>
<li><a href="#">List</a></li>
</ul>
</li>
</ul>
HEre is the Javascript:
<script type="text/javascript">
function menu()
{
uls=document.getElementById('navMenu').getElementsByTagName('ul');
for(i=0;i<uls.length;i++)
{
ul=document.getElementById('navMenu').getElementsByTagName('ul');
for(x=0;x<ul.length;x++)
{
if(!ul[x].getElementsByTagName('ul')[0])
{
hidem(uls[x]);
}
}
}
function show(uls)
{
uls.style.display='block';
}
function hidem(uls)
{
uls.style.display='none';
}
}
// Check if the browser supports DOM, and start the script if it does.
if(document.getElementById && document.createTextNode)
{
window.onload=menu;
}
</script>
My question is that : do you know how I can make this ULs that I hide how I
can make them apear onclick of the <ul><li><a> Links ?
I wrote the function but I can't really figure out how to loop thru the
specific <ul><li><a> ....
Sorry for the long code ... and sorry for my newbie question...
If you think that my whole script is wrong let me know ... But as it is it
hides succesfully the ULs ...
As you understand I want to create a simple Tree menu with CSS and DHTML or
what ever it is called...
Thanks
elements in a menu of the folowing structure:
<ul>
<li><a href="#">Page</a>
<ul>
<li><a href="#">Add</a></li>
<li><a href="#">List</a></li>
</ul>
</li>
<li><a href="#" >News</a>
<ul>
<li><a href="#">Add</a></li>
<li><a href="#">List</a></li>
</ul>
</li>
</ul>
HEre is the Javascript:
<script type="text/javascript">
function menu()
{
uls=document.getElementById('navMenu').getElementsByTagName('ul');
for(i=0;i<uls.length;i++)
{
ul=document.getElementById('navMenu').getElementsByTagName('ul');
for(x=0;x<ul.length;x++)
{
if(!ul[x].getElementsByTagName('ul')[0])
{
hidem(uls[x]);
}
}
}
function show(uls)
{
uls.style.display='block';
}
function hidem(uls)
{
uls.style.display='none';
}
}
// Check if the browser supports DOM, and start the script if it does.
if(document.getElementById && document.createTextNode)
{
window.onload=menu;
}
</script>
My question is that : do you know how I can make this ULs that I hide how I
can make them apear onclick of the <ul><li><a> Links ?
I wrote the function but I can't really figure out how to loop thru the
specific <ul><li><a> ....
Sorry for the long code ... and sorry for my newbie question...
If you think that my whole script is wrong let me know ... But as it is it
hides succesfully the ULs ...
As you understand I want to create a simple Tree menu with CSS and DHTML or
what ever it is called...
Thanks