jQuery實(shí)現(xiàn)當(dāng)前頁面標(biāo)簽高亮顯示的方法

字號(hào):


    這篇文章主要介紹了jQuery實(shí)現(xiàn)當(dāng)前頁面標(biāo)簽高亮顯示的方法,涉及jQuery通過自定義函數(shù)操作css樣式的技巧,非常具有實(shí)用價(jià)值,需要的朋友可以參考下
    本文實(shí)例講述了jQuery實(shí)現(xiàn)當(dāng)前頁面標(biāo)簽高亮顯示的方法。分享給大家供大家參考。具體實(shí)現(xiàn)方法如下:
    function nav(name, csskey,cssvalue) {
    var url = window.location.pathname + window.location.search;
    var v1 = "";
    $(name).each(function () {
    v1 = "/" + $(this).attr("href");
    if (v1 == url) {
    var v2 = $(this).css(csskey, cssvalue);
    }
    })
    }
    用法如下:
    <script src="Scripts/commo.js" type="text/javascript"></script>
    <script type="text/javascript">
    window.onload = function () {
    nav(".top ul li a", "background-color", "rgb(255,89,0)");
    }
    </script>
    希望本文所述對(duì)大家的jQuery程序設(shè)計(jì)有所幫助。