twitter-bootstrap 推特引导程序。活动菜单项标记

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/15295592/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-21 16:35:38  来源:igfitidea点击:

Twitter Bootstrap. Active menu item marking

twitter-bootstrapmenumenuitem

提问by Wolter

I use standart twitter bootstrap menu:

我使用标准的 twitter 引导菜单:

<ul class="nav nav-pills">
<li><a href="#">...</a></li>
<li><a href="#">...</a></li>
</ul>

How to mark active menu item?

如何标记活动菜单项?

回答by Chris

You just have to add "active" in your li like :

你只需要在你的 li 中添加“active”,比如:

<li class="active">
    <a href="#"></a> 
</li>

回答by ashley

        var storedListItem = sessionStorage.getItem('selectedListItem');
        $("ul.nav > li > a:eq("+(storedListItem)+")").addClass("active");
        $("ul.nav > li").on("click",function(){
            var index = $(this).index('ul.nav > li');
            var selectedListItem = index;
            sessionStorage.setItem('selectedListItem', JSON.stringify(selectedListItem));
        });