简体   繁体   English

Bootstrap导航栏子菜单活动状态不起作用

[英]Bootstrap navbar submenu Active State not working

Bootstrap navbar Active State is not working. Bootstrap导航栏活动状态不起作用。

I have bootstrap v3. 我有bootstrap v3。

I use the class="active" on mynavbar on its submenu when I collapse none work. 当我收紧所有工作时,在其子菜单上的mynavbar上使用class =“ active”。

Here is my code with js/css/bootstrap files I have included: 这是我包含的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>

You didn't show us enough HTML to see exactly what you are doing wrong, but it looks like you're trying to get the active class to work on a bootstrap dropdown-menu . 您没有向我们显示足够的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 DEMO

Try this 尝试这个

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM