本文介紹了如何在主頁菜單中突出顯示活動頁面?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!
問題描述
我在 masterpage
(在 ASP.NET 網站中)中有一個菜單,我想在 masterpage 菜單和子菜單中突出顯示活動頁面.
I have a menu inside a masterpage
(in a ASP.NET Web site), and i want to highlight active page in masterpage menu and submenus.
HTML:
<ul id="nav" class="sf-menu">
<li class="current-menu-item"><a href="index.html">Home</a></li>
<li><a href="page.html">menu-2</a>
<ul>
<li><a href="page-full.html">full</a></li>
<li><a href="page-features.html">featurs</a></li>
<li><a href="page-typography.html">typography</a></li>
</ul>
</li>
</ul>
CSS:
#nav>li.current-menu-item>a,
#nav>li.current_page_item>a{
color: #fe8300;
}
提前致謝.
推薦答案
最后我用 jQuery
解決了我的問題:
finally i solved my problem with using jQuery
:
var str=location.href.toLowerCase();
$("#nav li a").each(function() {
if (str.indexOf($(this).attr("href").toLowerCase()) > -1) {
$("li.current-menu-item").removeClass("current-menu-item");
$(this).parent().addClass("current-menu-item");
}
});
$("li.current-menu-item").parents().each(function(){
if ($(this).is("li")){
$(this).addClass("current-menu-item");
}
});
這篇關于如何在主頁菜單中突出顯示活動頁面?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!
【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!