[我正在使用jQuery来检查浏览器的URL是否与我的链接href中的URL匹配,问题出在我检查之后,我试图将链接匹配的li标记类设置为“活动”,但是下面的这段代码是将链接标签设置为活动标签而不是li标签
$(function(){
var current = location.pathname;
$('#nav li a').each(function(){
var $this = $(this);
// if the current path is like this link, make it active
if($this.attr('href') === current){
$this.addClass('active');
}
})
})