Bootstrap navbar子菜单Active State无法正常工作

时间:2015-08-24 00:23:36

标签: javascript jquery html css twitter-bootstrap

Bootstrap navbar Active State无效。

我有bootstrap v3。

当我崩溃时,我在子菜单上的mynavbar上使用class =“active”。

这是我包含的js / css / bootstrap文件的代码:

                        <li class="active">
                            <a href="javascript:;" data-toggle="collapse" data-target="#demoadmin">
                                <i class="fa fa-fw fa-wrench"></i>Administrator Menu <i class="fa fa-fw fa-caret-down"></i>
                            </a>
                            <ul id="demoadmin" class="collapse in">
                                <li class="active">
                                    <a href="linkmanagement.php#">Links Editor</a>
                                </li>

                                <li>
                                    <a href="editortable.php">News Editor</a>
                                </li>
                                <li>
                                    <a href="main_category.php">Main Category Editor</a>
                                </li>
                                <li>
                                    <a href="sub_category.php">Sub Category Editor</a>
                                </li>
                                <li>
                                    <a href="editorprofile.php">Profile Team Editor</a>
                                </li>
                            </ul>
                        </li>

2 个答案:

答案 0 :(得分:0)

你没有向我们展示足够的HTML来确切地看到你做错了什么,但看起来你正试图让active类来处理bootstrap dropdown-menu

   <li class="dropdown active">
        <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">
            <i class="fa fa-fw fa-wrench"></i>Administrator Menu <i class="fa fa-fw fa-caret-down"></i>
        </a>
        <ul class="dropdown-menu">
            <li class="active">
                <a href="linkmanagement.php#">Links Editor</a>
            </li>

            <li>
                <a href="editortable.php">News Editor</a>
            </li>
            <li>
                <a href="main_category.php">Main Category Editor</a>
            </li>
            <li>
                <a href="sub_category.php">Sub Category Editor</a>
            </li>
            <li>
                <a href="editorprofile.php">Profile Team Editor</a>
            </li>
        </ul>
    </li>

DEMO

答案 1 :(得分:0)

尝试

$(document).ready(function(){
   $(".active").removeClass("active");
   $(".dropdown-menu li").addClass("active");
});