有没有JS高亮当前菜单的方法,不想用程序控制 有JS控制的方法吗,搜一搜,找不到适合的进入另一个页面后,当前菜单高亮在二 三级菜单下,高亮的还是第一级菜单JS JQ的方法都行 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 1.取得当前网页地址URL2.判断该URL属于哪个菜单(找到其第一级菜单)3.高亮显示该菜单 代码来源 http://static.jquery.com/files/rocker/scripts/custom.jsvar loc = window.location.href;//strip the existing current state$('#jq-secondaryNavigation .jq-current').removeClass('jq-current');//add class to current section...//Downloadif(loc.indexOf('http://docs.jquery.com/Downloading_jQuery') > -1){ $('#jq-secondaryNavigation .jq-download').addClass('jq-current');}//Tutorialselse if(loc.indexOf('http://docs.jquery.com/Tutorials') > -1){ $('#jq-secondaryNavigation .jq-tutorials').addClass('jq-current');}//Discussionelse if(loc.indexOf('http://docs.jquery.com/Discussion') > -1){ $('#jq-secondaryNavigation .jq-discussion').addClass('jq-current');}//UI within docselse if(loc.indexOf('http://docs.jquery.com/UI') > -1){ $('#jq-primaryNavigation .jq-current').removeClass('jq-current'); $('#jq-primaryNavigation .jq-ui').addClass('jq-current'); $('#jq-secondaryNavigation .jq-documentation').addClass('jq-current');}//Aboutelse if(loc.indexOf('http://docs.jquery.com/About') > -1){ $('#jq-primaryNavigation .jq-current').removeClass('jq-current'); $('#jq-primaryNavigation .jq-about').addClass('jq-current');}//Donateelse if(loc.indexOf('http://docs.jquery.com/Donate') > -1){ $('#jq-primaryNavigation .jq-current').removeClass('jq-current'); $('#jq-primaryNavigation .jq-donate').addClass('jq-current');}//Docs, in generalelse if(loc.indexOf('http://docs.jquery.com/') > -1){ $('#jq-secondaryNavigation .jq-documentation').addClass('jq-current');}// Develse if(loc.indexOf('http://dev.jquery.com/') > -1){ $('#jq-secondaryNavigation .jq-bugTracker').addClass('jq-current');}//plugins popularelse if(loc.indexOf('http://plugins.jquery.com/most_popular') > -1){ $('#jq-secondaryNavigation .jq-popularPlugins').addClass('jq-current');}//plugins latestelse if(loc.indexOf('http://plugins.jquery.com/latest_releases') > -1){ $('#jq-secondaryNavigation .jq-latestReleases').addClass('jq-current');}//plugins browseelse if(loc.indexOf('http://plugins.jquery.com/project/Plugins') > -1){ $('#jq-secondaryNavigation .jq-browseCategories').addClass('jq-current');}//plugins lateselse if(loc.indexOf('http://plugins.jquery.com/project/Plugins/name') > -1){ $('#jq-secondaryNavigation .jq-allPlugins').addClass('jq-current');}用url判断当前的菜单,jq-current 是当前菜单的class 想通过js自动提交表单,但是却不执行Onsubmit的事件,怎么办? jquery data对象 不修改代码open一个新窗口 Javascript的Sort函数? 谁帮我做一个课程表修改程序!(急) 请问javascript var a={} 是什么意思 急!javacsript中如何实现string到int的类型转换,在线等 怎样挪动网页相关条目的位置?——我的网页都挤在一块儿了 动态树状菜单问题! 用什么替代iframe? 框架嵌套框架,怎么跳出最外层的框架? 广告代码浮动效果-请求帮助-826833229
2.判断该URL属于哪个菜单(找到其第一级菜单)
3.高亮显示该菜单
//strip the existing current state
$('#jq-secondaryNavigation .jq-current').removeClass('jq-current');//add class to current section...
//Download
if(loc.indexOf('http://docs.jquery.com/Downloading_jQuery') > -1){
$('#jq-secondaryNavigation .jq-download').addClass('jq-current');
}
//Tutorials
else if(loc.indexOf('http://docs.jquery.com/Tutorials') > -1){
$('#jq-secondaryNavigation .jq-tutorials').addClass('jq-current');
}
//Discussion
else if(loc.indexOf('http://docs.jquery.com/Discussion') > -1){
$('#jq-secondaryNavigation .jq-discussion').addClass('jq-current');
}
//UI within docs
else if(loc.indexOf('http://docs.jquery.com/UI') > -1){
$('#jq-primaryNavigation .jq-current').removeClass('jq-current');
$('#jq-primaryNavigation .jq-ui').addClass('jq-current');
$('#jq-secondaryNavigation .jq-documentation').addClass('jq-current');
}
//About
else if(loc.indexOf('http://docs.jquery.com/About') > -1){
$('#jq-primaryNavigation .jq-current').removeClass('jq-current');
$('#jq-primaryNavigation .jq-about').addClass('jq-current');
}
//Donate
else if(loc.indexOf('http://docs.jquery.com/Donate') > -1){
$('#jq-primaryNavigation .jq-current').removeClass('jq-current');
$('#jq-primaryNavigation .jq-donate').addClass('jq-current');
}
//Docs, in general
else if(loc.indexOf('http://docs.jquery.com/') > -1){
$('#jq-secondaryNavigation .jq-documentation').addClass('jq-current');
}
// Dev
else if(loc.indexOf('http://dev.jquery.com/') > -1){
$('#jq-secondaryNavigation .jq-bugTracker').addClass('jq-current');
}
//plugins popular
else if(loc.indexOf('http://plugins.jquery.com/most_popular') > -1){
$('#jq-secondaryNavigation .jq-popularPlugins').addClass('jq-current');
}
//plugins latest
else if(loc.indexOf('http://plugins.jquery.com/latest_releases') > -1){
$('#jq-secondaryNavigation .jq-latestReleases').addClass('jq-current');
}
//plugins browse
else if(loc.indexOf('http://plugins.jquery.com/project/Plugins') > -1){
$('#jq-secondaryNavigation .jq-browseCategories').addClass('jq-current');
}
//plugins lates
else if(loc.indexOf('http://plugins.jquery.com/project/Plugins/name') > -1){
$('#jq-secondaryNavigation .jq-allPlugins').addClass('jq-current');
}用url判断当前的菜单,jq-current 是当前菜单的class