获取导航的当前状态

$(document).ready(function(){
    $("#nav a").each(function(){  
        $this = $(this);  
        if($this[0].href==String(window.location)){ 
            $(this).parent("li").addClass("active");
        }  
    });
});
原文地址:https://www.cnblogs.com/horanly/p/6101242.html