好吧,所以我在这里工作。让我知道是否有更好的方式,如果你遇到这个职位...
我最终创建了一个称为MyTitle的元标签,并给它内容来比较一个ID,然后显示基于该元标签的UL。
$(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();
等..........