Jump to content

[SOLVED] Show Hide Menus


dropfaith

Recommended Posts

How would i make this so if theres more then one menu click on them closes all other open menus

 

http://dropfaithproductions.com/test/blogs.php its live there  i just need it so you can only have one menu open at a time

 

  function showElement(layer){
var myLayer = document.getElementById(layer);
if(myLayer.style.display=="none"){
myLayer.style.display="block";
myLayer.backgroundPosition="top";
} else {
myLayer.style.display="none";
}
}

 

				<li><a href="#" class="button" onclick="javascript:showElement('v-menu2')">Links</a>
				<ul id="v-menu2" class="v-menu2" style="display:none;">

Link to comment
Share on other sites

Give this a try:

function showElement (layer){
var hideOthers = document.getElementsByTagName("ul"), hlen = hideOthers.length;
while (--hlen > -1) {
	var tehElem = hideOthers[hlen];
	if (tehElem.id !== undefined && tehElem.id != layer && tehElem.className == "v-menu" && tehElem.style.display != "none") tehElem.style.display = "none";
}
var myLayer = document.getElementById(layer);
if (myLayer.style.display == "none") {
	myLayer.style.display = "block";
	myLayer.backgroundPosition = "top";
}
else {
	myLayer.style.display="none";
}
}

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.