为什么在一个for语句中定义颜色就不能实现
<script type="text/javascript"> window.onload=function() { var s = document.getElementsByTagName("tr")[0]; for (var i=0;i<s.length;i++) { } s[i].onmouseover = function () { s[i].style = "background-color:red"; } s[i].onmouseout = function () { s[i].style = "background-color:green"; } } } </script>