I have a simple menu that slides down more UL when the parent LI is clicked, if there is a child UL to follow...
I am trying to make it so when the menu is in a certain directory it will have that menu expanded by default rather than closed. I have tried a few things, but am just not getting it to work. Currently I have a IF statement comparing the PATHNAME with the Varibles and just telling that ID to keep the UL open... That has been as close as I can get.
Any suggestions on how to make the UL stay open if the page url is the same as the parent UL HREF?
You can see the code here: http://jsfiddle.net/RvGMQ/
Thanks!
Ok, so I got something to work here. Let me know if there is a better way if you come across this post...
I ended up creating a Meta Tag called MyTitle and gave it content to compare an ID to then display UL based on that Meta Tag.
$(document).ready(function() {
$("#menu ul ul").hide();
$("#menu ul li").click(function()
{
$(this).next("ul").slideToggle(300).siblings("ul").slideUp("slow");
});
//created a meta tag called MyTitle to use as a way to open menu when needed. This function checks for the value of MyTitle. Got this from (http://forums.macrumors.com/showthread.php?t=569947)
var mytitle;
var metas = document.getElementsByTagName('meta');
for (var x=0,y=metas.length; x<y; x++) {
if (metas[x].name.toLowerCase() == "mytitle") {
mytitle = metas[x];
}
}
//Find the page currently on and display menu if need be.
var title = "" + mytitle.content;
if(title == "Resources")
$("ul #resources").show();
if(title == "Conferences")
$("ul #conferences").show();
etc..........