jQuery簡單實現網頁選項卡特效,jquery選項卡特效

來源:互聯網
上載者:User

jQuery簡單實現網頁選項卡特效,jquery選項卡特效

CSS:

複製代碼 代碼如下:
        .clear{clear:both; height:0px; overflow:hidden;}
        .tab{width:400px; font-size:12px;}
        .tab_menu ul{padding:0px;margin:0px;}
        .tab_menu li{list-style:none; display:block; float:left;
            background:#C2CEFE; height:22px; line-height:22px;
            padding: 0px 8px; margin-right:6px; border:#86B4CA 1px solid;
        }
        .box{width:400px; height:200px; overflow:hidden; border:#A8C9D9 1px solid; padding:10px 8px; }
        .tab_menu ul li.selected{background:#dadada; cursor:pointer; }
        .hide{display:none;}

jQuery:

複製代碼 代碼如下:
        $(function() {
            var $menu_li = $("div.tab_menu ul li");  //選取網頁選項卡
            $menu_li.click(function(){
                $(this).addClass("selected") //當前<li>高亮
                        .siblings().removeClass("selected"); //去掉其它同輩<li>的高亮
                var index = $menu_li.index( $(this) ); //找到<li>子節點的索引
                $("div.tab_box > div").eq(index).show() //索引為N的DIV顯示出來
                        .siblings().hide();            //其它的選項卡隱藏
            })
        }) 

html:

複製代碼 代碼如下:
 <div class="tab">
    <div class="tab_menu">
        <ul>
            <li class="selected">個人資訊</li>
            <li class="selected">我的照片</li>
            <li class="selected">我的部落格</li>
            <div class="clear"></div>
        </ul>
    </div>
    <div class="tab_box">
        <div class="box">我的QQ:123456</div>
        <div class="box hide">hi </div>
        <div class="box hide"> hello <br> </div>
    </div>
</div>

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.