JavaScript導(dǎo)航腳本判斷當(dāng)前導(dǎo)航
更新時間:2016年07月12日 16:30:04 作者:zhaoyingyatou
這篇文章主要介紹了JavaScript導(dǎo)航腳本判斷當(dāng)前導(dǎo)航的相關(guān)資料,非常不錯,具有參考借鑒價值,需要的朋友可以參考下
廢話不多說,直接給大家貼代碼了。
<script> $(function () { //highlight current / active link 左側(cè)導(dǎo)航判斷當(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è)置為活動狀態(tài) $(this).find("i:first").toggleClass("glyphicon-minus"); }); $(".main-menu a").click(function () { //更換其他導(dǎo)航的加減號圖標(biāo) $(this).parent('li').siblings(".active").find("i:first").toggleClass("glyphicon-minus"); //alert($(this).index()); //去掉其他導(dǎo)航的點擊樣式并折疊 $(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)航,希望對大家有所幫助,如果大家有任何疑問請給我留言,小編會及時回復(fù)大家的。在此也非常感謝大家對腳本之家網(wǎng)站的支持!
您可能感興趣的文章:
相關(guān)文章
詳解JavaScript基于面向?qū)ο笾畡?chuàng)建對象(2)
這篇文章主要介紹了JavaScript基于面向?qū)ο笾畡?chuàng)建對象,詳細(xì)的分析面向?qū)ο蟮脑头绞揭约捌渌C合的方式,感興趣的小伙伴們可以參考一下2015-12-12JavaScript數(shù)組Array的一些常用方法總結(jié)
JavaScript的Array對象是用于構(gòu)造數(shù)組的全局對象,數(shù)組是類似于列表的高階對象,下面這篇文章主要給大家介紹了關(guān)于JavaScript數(shù)組Array的一些常用方法,需要的朋友可以參考下2021-11-11Javascript封裝id、class與元素選擇器方法示例
這篇文章主要給大家介紹了Javascript封裝id、class與元素選擇器的方法,文中給出了詳細(xì)的示例代碼,對大家的理解和學(xué)習(xí)具有一定的參考價值,需要的朋友們下面來一起看看吧。2017-03-03寫出更好的JavaScript程序之undefined篇(中)
前一篇我介紹了幾種廣為使用的利用undefined這個概念值的辦法,這一篇我會介紹一些不太常見的辦法,其中還包括一個很巧妙的,我個人覺得很值得推廣的辦法。2009-11-11