1. 程式人生 > >獲取位址列特定字元後面的字元

獲取位址列特定字元後面的字元

 var abouturl=location.href;//獲取地址
    var str_after = abouturl.split("#")[1];//獲取後面字元
    $("li").each(function () {
        var a=$(this).children().attr('href');
        if(a=='#'+str_after){
            $("li a").removeClass("active");
            $(this).children().addClass("active")
        }
    });