问答详情
源自:9-22 编程练习

9-2编程练习中i=1,为什么从1开始

window.onload = function(){
           var trs = document.getElementsByTagName('tr');
           for(var i = 1; i < trs.length; i++){
                trs[i].onmouseover = function(){
                     this.style.backgroundColor = "#f2f2f2";
                }
                trs[i].onmouseout = function(){
                     this.style.backgroundColor = "#fff";
                }
          }
        }

提问者:LanceChou 2016-09-30 19:49

个回答

  • coneco
    2016-10-01 00:33:14

    因为第一行是表头不需要变色