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

函数封装问题

 window.onload = function(){

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

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

          {

            bagChange(tr[i]);

          }

      }         

     function bagChange(abj){

         

            abj.onmouseover=function(){

            this.style.backgroundColor="#f2f2f2";

        }

           abj.onmouseout=function(){

            this.style.backgroundColor="#fff";

        }

     }

在这里面,我讲abj换成tr[i]就不行了,这是为什么


正在回答

1 回答

把下面的 this 换成 abj  就行了  

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

举报

0/150
提交
取消
JavaScript进阶篇
  • 参与学习       468297    人
  • 解答问题       21893    个

本课程从如何插入JS代码开始,带您进入网页动态交互世界

进入课程

函数封装问题

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