码迷,mamicode.com
首页 > 其他好文 > 详细

导航高亮

时间:2016-04-27 22:42:45      阅读:359      评论:0      收藏:0      [点我收藏+]

标签:

http://www.cnblogs.com/Dtscal/p/acv.html

 

 

if(nowUrl == ctx+"/center/personal/index.xhtml" || nowUrl == ctx+"/center/school/index.xhtml" || nowUrl == ctx+"/center/company/index.xhtml" ){
				//首页高亮
				$("#indexMenu").addClass("hover1");
			}else{
				$("a").each(function(){
					var getUrl = $(this).attr("href");
					if(getUrl == nowUrl ){
						var menuId= $(this).attr("data-fatherId");
						if(menuId){
							$("#"+menuId).addClass("hover1");
							return false;
						}
						
					}
				})
			}

var urlstr = location.href;    //获取浏览器的url
 var urlstatus=false;        //标记
 //遍历导航div
 $("#menu a").each(function () {
//判断导航里面的rel和url地址是否相等
  if ((urlstr + /).indexOf($(this).attr(rel)) > -1&&$(this).attr(rel)!=‘‘) {
   $(this).addClass(cur); urlstatus = true;
  } else {
   $(this).removeClass(cur);
  }
 });
//当前样式保持
 if (!urlstatus) {$("#menu a").eq(0).addClass(cur); }

明天来完善



导航高亮

标签:

原文地址:http://www.cnblogs.com/hupan508/p/5440466.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!