[js] - 为子节点增加鼠标移入和移出的样式

var cards = document.querySelectorAll(".card");
for (let index = 0; index < cards.length; index++) {
    const card = cards[index];
    card.addEventListener("mouseover",function(){
        var chils = this.childNodes
        for (let i = 0; i < chils.length; i++) {
            let e = chils[i];
            if(e.nodeType==1 && e.classList.contains(‘card-info‘)){
                e.classList.remove("fontDown");
                e.classList.add("fontUp");

            }
        }
    },false)
    card.addEventListener("mouseout",function(){
        var chils = this.childNodes
        for (let i = 0; i < chils.length; i++) {
            let e = chils[i];
            if(e.nodeType==1 && e.classList.contains(‘card-info‘)){
                e.classList.remove("fontUp");
                e.classList.add("fontDown");
            }
        }
           
    },false)
}

 

[js] - 为子节点增加鼠标移入和移出的样式

上一篇:.Net递归加载菜单树


下一篇:JS 处理图片平铺问题