Bootstrap 小功能

<div class="container">
        <div class="navbar-header">
            <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#demo-navbar">
                <span class="sr-only">切换导航</span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
            </button>
            <a class="navbar-brand" href="#">浏览器</a>
        </div>
        <div class="navbar-collapse collapse" id="demo-navbar">
            <ul class="nav navbar-nav">
                <li class="active"><a href="#ad-carousel">综述</a></li>
                <li><a href="#summary-container">简述</a></li>
                <li class="dropdown">
                    <a href="#" class="dropdown-toggle" data-toggle="dropdown">特点 <span class="caret"></span></a>
                    <ul class="dropdown-menu" role="menu" >
                        <li><a href="#tab-chrome" data-tab="tab-chrome">Chrome</a></li>
                        <li><a href="#tab-firefox" data-tab="tab-firefox">Firefox</a></li>
                        <li><a href="#tab-safari" data-tab="tab-safari">Safari</a></li>
                        <li><a href="#tab-opera" data-tab="tab-opera">Opera</a></li>
                        <li><a href="#tab-ie" data-tab="tab-ie">IE</a></li>
                    </ul>
                </li>
                <li><a href="#" data-toggle="modal" data-target="#about-modal">关于</a></li>
            </ul>
        </div>
    </div>

  

 

 

<ul class="nav nav-tabs" role="tablist" id="tab-list">
        <li class="active"><a href="#tab-chrome" role="tab" data-toggle="tab">Chrome</a></li>
        <li><a href="#tab-firefox" role="tab" data-toggle="tab">Firefox</a></li>
        <li><a href="#tab-safari" role="tab" data-toggle="tab">Safari</a></li>
        <li><a href="#tab-opera" role="tab" data-toggle="tab">Opera</a></li>
        <li><a href="#tab-ie" role="tab" data-toggle="tab">IE</a></li>
    </ul>

  

js

 $(document).ready(function(){
         $("#demo-navbar .dropdown-menu a").click(function(){
             var href=$(this).attr("href");
             $("#tab-list a[href='"+href+"']").tab("show");
         
         
         
         })
      });

  

 

 

效果:

 

posted @ 2017-09-19 09:17  1点  阅读(178)  评论(0编辑  收藏  举报