为了账号安全,请及时绑定邮箱和手机立即绑定

鼠标悬浮改变背景色,这样写就不行呢?

      window.onload = function(){

                  

     // 鼠标移动改变背景,可以通过给每行绑定鼠标移上事件和鼠标移除事件来改变所在行背景色。

       var mors = document.getElementsByTagName("tr"); 

       for(var i=0;i<mors.length;i++){

           //bgcChange(mors[i])

            mors[i].onmouseover=function(){

            mors[i].style.backgroundColor="#f2f2f2";

         }

            mors[i].onmouseout=function(){

            mors[i].style.backgroundColor="#f2f2f2";

         }

       }

}

正在回答

3 回答

https://img1.sycdn.imooc.com//5afe75b60001aab411610604.jpg如有错误请指正

0 回复 有任何疑惑可以回复我~
var tr=document.getElementsByTagName("tr");
for(var i=0;i<tr.length;i++){
    tr[i].onmouseover=function(){
        this.style.backgroundColor="#f2f2f2";
    }
    tr[i].onmouseout=function(){
        this.style.backgroundColor="#fff";
    }
}


1 回复 有任何疑惑可以回复我~

举报

0/150
提交
取消

鼠标悬浮改变背景色,这样写就不行呢?

我要回答 关注问题
意见反馈 帮助中心 APP下载
官方微信