$(document).ready(function(){
    $("#nav a").each(function(){  
        $this = $(this);  
        if($this[0].href==String(window.location)){ 
            $(this).parent("li").addClass("active");
        }  
    });
});

 

相关文章: