Bootstrap accordion with navigation bar to implement the common menu bar

Source: Internet
Author: User

Effect

HTML code
    <Divclass= "sidebar">        <Divclass= "Mc-search">            <Divclass= "Input-group">                <inputtype= "text"class= "Form-control"placeholder= "Search ...">            <spanclass= "Input-group-btn">                <Buttontype= "button"class= "Btn Btn-default"><Iclass= "fa Fa-search"></I></Button>            </span>            </Div>        </Div>        <Divclass= "NavBar Navbar-default"ID= "Mycollapse">            <!--<ul class= "nav navbar-nav nav-pills nav-stacked" > -            <ulclass= "Nav nav-pills nav-stacked">                <Li><ahref="#"><Iclass= "fa fa-dashboard fa-fw"></I>Dashbord</a></Li>                <Li>                    <ahref= "#second-level-1"class= "Second-level accordion-toggle"Data-toggle= "Collapse"data-parent= "#mycollapse">                        <Iclass= "fa fa-table fa-fw"></I>Table<Iclass= "fa fa-angle-left pull-right"></I>                    </a>                    <ulclass= "nav collapse"ID= "Second-level-1">                        <Li><ahref="#">Database testing</a></Li>                        <Li><ahref="#">Database testing</a></Li>                        <Li><ahref="#">Database testing</a></Li>                    </ul>                </Li>                <Li><ahref="#"><Iclass= "fa fa-bar-chart fa-fw"></I>Chart</a></Li>                <Li><ahref="#"><Iclass= "fa fa-edit fa-fw"></I>Form</a></Li>                <Li>                    <ahref= "#second-level-2"class= "Second-level accordion-toggle"Data-toggle= "Collapse"data-parent= "#mycollapse">                        <Iclass= "fa fa-table fa-fw"></I>Table<Iclass= "fa fa-angle-left pull-right"></I>                    </a>                    <ulclass= "nav collapse"ID= "Second-level-2">                        <Li><ahref="#">Database testing</a></Li>                        <Li><ahref="#">Database testing</a></Li>                        <Li><ahref="#">Database testing</a></Li>                    </ul>                </Li>                <Li><ahref="#"><Iclass= "fa fa-wrench fa-fw"></I>UI Element</a></Li>                <Li>                    <ahref= "#second-level-3"class= "Second-level accordion-toggle"Data-toggle= "Collapse"data-parent= "#mycollapse">                        <Iclass= "fa fa-table fa-fw"></I>Table<Iclass= "fa fa-angle-left pull-right"></I>                    </a>                    <ulclass= "nav collapse"ID= "Second-level-3">                        <Li><ahref="#">Database testing</a></Li>                        <Li><ahref="#">Database testing</a></Li>                        <Li><ahref="#">Database testing</a></Li>                    </ul>                </Li>            </ul>        </Div>    </Div>
JS Code
$(function() {$ (document). On (' Click ', '. Accordion-toggle ',function(event) {event.stoppropagation (); var$ This= $( This); varParent = $ This. Data (' Parent '); varActives = Parent && $ (parent). Find ('. collapse.in ')); //From Bootstrap itself        if(Actives &&actives.length) {actives.data (' Collapse ');Actives.collapse (' Hide '); }        vartarget = $ This. attr (' data-target ') | | (href = $ This. attr (' href ')) && href.replace (/.* (? =#[^\s]+$)/, ");//Strip for IE7$ (target). Collapse (' Toggle '); });})
Effect
    1. Click on one to expand the drop-down menu.
    2. Click another if there is a drop-down menu to automatically close the previous expand

Bootstrap accordion with navigation bar to implement the common menu bar

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.