我有多个div作为按钮,我使用循环和addEventListener
来触发MouseOver
和MouseOut
事件,但无法将div内的孩子作为目标,谢谢您的帮助
var btn = document.querySelectorAll('.c-btn');
var btnback = document.querySelectorAll('.btnback');
for (i = 0; i < btn.length; i++) {
btn[i].addEventListener("mouseover", function(event){
this.classList.add("rotatinEffect");
btchild[i].style.backgroundColor = 'red'
});
btn[i].addEventListener("mouseout", function(){
console.log('out')
this.classList.remove("rotatinEffect");
btchild[i].style.backgroundColor = 'blue'
});
}