onload

通过window.onload触发下面事件

 window.onload = function(){

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

         for (var i = 1;i < mytr.length; i++){

             mytr[i].onmouseover = function(){

                 this.style.backgroundColor = "red";

             }

              mytr[i].onmouseout = function(){

                 this.style.backgroundColor = "white";

             }

         }

      }

        

猜你喜欢

转载自www.cnblogs.com/666666CFH88888888/p/8969645.html