<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
<script language="javascript" type="text/javascript";>
   window.onload = function(){
   var li = document.getElementsByTagName("li");
   for (var j=0; j < li.length; j++){
    li[i].onmouseover = function(){
this.style.backgroundcolor='blue';
};
li[i].onmouseout = function(){
this.style.backgroundColor='white';
};
   }
   };
</script>
</head><body>
<ul>
   <li id="ee">everywhereeverywhere</li>
   <li id="text">texttexttexttexttexttext</li>
   <li id="text">texttexttexttexttexttext</li>
</ul>
</body>
</html>

解决方案 »

  1.   

    for (var j=0; j < li.length; j++){
    li[i].onmouseover = function(){
    this.style.backgroundcolor='blue';
    };
    li[i].onmouseout = function(){
    this.style.backgroundColor='white';
    };你for循环里面变量是j 而遍历集合的时候li[i]  用的是i. 当然有问题啦。
      

  2.   


    window.onload = function(){
    var li = document.getElementsByTagName("li");
    for (var j=0; j < li.length; j++){
    li[j].onmouseover = function(){
    this.style.backgroundcolor='blue';
    };
    li[j].onmouseout = function(){
    this.style.backgroundColor='white';
    };
    }
    };
      

  3.   

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
    <title>无标题文档</title>
    <script language="javascript" type="text/javascript";>
      window.onload = function(){
    var li = document.getElementsByTagName("li");
    for (var i=0; i< li.length; i++){
    li[i].onmouseover = function(){
    this.style.backgroundColor='blue';
    };
    li[i].onmouseout = function(){
    this.style.backgroundColor='white';
    };
    }
    };
    </script>
    </head><body>
    <ul>
      <li id="ee">everywhereeverywhere</li>
      <li id="text">texttexttexttexttexttext</li>
      <li id="text">texttexttexttexttexttext</li>
    </ul>
    </body>
    </html>
      

  4.   

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
    <title>无标题文档</title>
    <script language="javascript" type="text/javascript";>
      window.onload = function(){
    var li = document.getElementsByTagName("li");
    for (var j=0; j < li.length; j++){ li[j].onmouseover = function(){
    this.style.background= '#00ff00';
    };
    li[j].onmouseout = function(){
    this.style.background= '#ddff00';
    };
    }
    };
    </script>
    </head><body>
    <ul>
      <li id="ee">everywhereeverywhere</li>
      <li id="text">texttexttexttexttexttext</li>
      <li id="text">texttexttexttexttexttext</li>
    </ul>
    </body>
    </html>
      

  5.   

    粗心大萝卜,你好!!!
    主要有两个问题:
    1)li[i] 这里用i,可for循环中使用的是j,该打屁股;
    2)li[i].onmouseover = function(){
    this.style.backgroundcolor='blue';
    };
    的backgroundcolor应该为backgroundColor,C要大写~~~粗心大萝卜,开心了不?
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
    <title>无标题文档</title>
    <script language="javascript" type="text/javascript";>
      window.onload = function(){
    var li = document.getElementsByTagName("li");
    for (var i=0; i < li.length; i++){
    li[i].onmouseover = function(){
    this.style.backgroundColor='blue';
    };
    li[i].onmouseout = function(){
    this.style.backgroundColor='white';
    };
    }
    };
    </script>
    </head><body>
    <ul>
      <li id="ee">everywhereeverywhere</li>
      <li id="text1">texttexttexttexttexttext</li>
      <li id="text2">texttexttexttexttexttext</li>
    </ul>
    </body>
    </html>
      

  6.   

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
    <title>无标题文档</title>
    <script language="javascript" type="text/javascript";>
    window.onload = function(){
    var li = document.getElementsByTagName("li");
    for (var i=0;  i< li.length; i++){
    li[i].onmouseover = function(){
    this.style.backgroundColor='blue';
    };
    li[i].onmouseout = function(){
    this.style.backgroundColor='white';
    };
    }
    };</script>
    </head><body>
    <div>
    <ul>
      <li id="ee">everywhereeverywhere</li>
      <li id="text">texttexttexttexttexttext</li>
      <li id="text">texttexttexttexttexttext</li>
    </ul>
    </div>
    </body>
    </html>