js 導航指令碼 ,判斷當前置航

來源:互聯網
上載者:User

標籤:jquery   menu   導航指令碼   

<script>

    $(function () {

        //highlight current / active link   左側導航判斷當前活動導航

        $(‘ul.main-menu li a‘).each(function () {

            var wo = window.location.href.substring(window.location.href.lastIndexOf(‘/‘) + 1, window.location.href.lastIndexOf(‘.‘));


            if ($(this).attr(‘href‘) == (wo + ".html")) {

                $(this).parent().addClass(‘active‘);

                $(this).parents().addClass(‘active‘);

                $(this).parents(‘li‘).find("i:first").toggleClass("glyphicon-minus");

                $(this).parents(‘ul‘).slideDown();


            }else

                if (("dxs" == wo || "syd" == wo)&&($(this).attr(‘href‘)=="dbs.html")) {

                  

                    $(this).parent().addClass(‘active‘);

                    $(this).parents().addClass(‘active‘);

                    $(this).parents(‘li‘).find("i:first").toggleClass("glyphicon-minus");

                    $(this).parents(‘ul‘).slideDown();


            }

        });

   /*** begin 首頁左側菜單 */ 

    $(".main-menu a").click(function () {

        //將當前li設定為活動狀態

        $(this).find("i:first").toggleClass("glyphicon-minus");


    });

    $(".main-menu a").click(function () {

        //更換其他導航的加減號表徵圖

        $(this).parent(‘li‘).siblings(".active").find("i:first").toggleClass("glyphicon-minus");

        //alert($(this).index());

       

        //去掉其他導航的點擊樣式並摺疊

        $(this).parent(‘li‘).siblings(".active").removeClass("active").children("ul").slideUp(‘fast‘);

        $(this).next(‘ul‘).slideToggle(‘fast‘);

        $(this).parent(‘li‘).addClass(‘active‘);

    });


    /************** end 首頁左側菜單 */

})

</script>


js 導航指令碼 ,判斷當前置航

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.