<script>
let aList = document.querySelectorAll('a');
console.log(aList);
for (let index = 0; index < aList.length; index++) {
const element = aList[index];
element.addEventListener("click", function (e) {
let txt = e.srcElement.innerText;
element.style.color = "red";//点击则标红
for (let index = 0; index < aList.length; index++) {
const item = aList[index];
if (item.innerText !== txt) {
item.style.color = "black";//其他标黑
}
}
});
}
</script>
标签:index,菜单,标黑,aList,element,item,let,标红
From: https://www.cnblogs.com/anjun-xy/p/16595016.html