$(document).on("click",".nav-item>a",function(){
$(this).addClass("active").parent(".nav-item").siblings(".nav-item").children("a").removeClass("active")
})
})
如果好使,请给个采纳
<script>var a = document.querySelectorAll("a")
var className = ["food", "travel", "sport", "fashion"]
for (var i = 0i <a.lengthi++) {
a[i].className = className[i]
}
</script>
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)