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
https://forums.phpfreaks.com/topic/122066-solved-show-hide-menus/
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";
}
}

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.