JS 鼠标移动到a标签上背景颜色改变

2024-11-19 08:28:52
推荐回答(1个)
回答1:

onload=function(){
var as = document.getElementsByTagName("a");
for(var i=0;ias[i].onmouseenter=function(){
this.style.backgroundColor="red";

}

as[i].onmouseleave=function(){
this.style.backgroundColor="none";

}

}
}