背景颜色的文字 改变以及假如

var C=[“写代码1”,“写代码2”,“写代码3”,“写代码4”,“写代码5”,“写代码6”,“写代码7”,“写代码8”,“写代码9”,“写代码10”,“写代码11”,“写代码12”,]
var D=["","","","","","","","","","","","",]

    var   A=document.getElementsByClassName("a1")
    var    B=document.getElementById("w1")
     for(i=0; i< A.length;i++){
        A[i].index=i;
         A[i].onmouseover=function ()
        { this.style.backgroundColor="#FFFFFF"
         this.style.color="red"
         
         B.innerText=this.innerText+  C[this.index] ;

         }
         A[i].onmouseout=function ()
        { this.style.backgroundColor=" #424242"
         this.style.color="#FFFFFF"
         B.innerText=D[this.index]}
     }

猜你喜欢

转载自blog.csdn.net/weixin_44081699/article/details/85229513