好吧,所以我在這裏工作。讓我知道是否有更好的方式,如果你遇到這個職位...
我最終創建了一個稱爲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();
等..........