JavaScript導(dǎo)航腳本判斷當(dāng)前導(dǎo)航

字號(hào):


    這篇文章主要介紹了JavaScript導(dǎo)航腳本判斷當(dāng)前導(dǎo)航的相關(guān)資料,非常不錯(cuò),具有參考借鑒價(jià)值,需要的朋友可以參考下
    直接給大家貼代碼了。
    代碼如下:
    <script>
    $(function () {
    //highlight current / active link 左側(cè)導(dǎo)航判斷當(dāng)前活動(dòng)導(dǎo)航
    $('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 主頁左側(cè)菜單 */
    $(".main-menu a").click(function () {
    //將當(dāng)前l(fā)i設(shè)置為活動(dòng)狀態(tài)
    $(this).find("i:first").toggleClass("glyphicon-minus");
    });
    $(".main-menu a").click(function () {
    //更換其他導(dǎo)航的加減號(hào)圖標(biāo)
    $(this).parent('li').siblings(".active").find("i:first").toggleClass("glyphicon-minus");
    //alert($(this).index());
    //去掉其他導(dǎo)航的點(diǎn)擊樣式并折疊
    $(this).parent('li').siblings(".active").removeClass("active").children("ul").slideUp('fast');
    $(this).next('ul').slideToggle('fast');
    $(this).parent('li').addClass('active');
    });
    /************** end 主頁左側(cè)菜單 */
    })
    </script>
    以上所述是小編給大家介紹的JavaScript導(dǎo)航腳本判斷當(dāng)前導(dǎo)航,希望對(duì)大家有所幫助