Using a CSS based solution would be more elegant, but if you still want to do it programmatically, you could use the "mouseout" event to remove the style:(使用基于CSS的解决方案会更优雅,但是如果您仍然想以编程方式进行操作,则可以使用“ mouseout”事件来删除样式:)
let divShow = document.querySelectorAll('.grid-show');
for(i = 0; i < divShow.length; i++){
divShow[i].addEventListener('mouseover', function(event){
event.target.style.color = "orange"
})
divShow[i].addEventListener('mouseout', function(event){
event.target.style.color = "";
})
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…