$(".nav a").each(function(){ if($(this).attr('href') == location.href){ $(this).css('background-color','#f00'); }})思路就是对比你导航条中的链接和页面的链接是否一致