obj.className="imgover";imgover 要加引号;

解决方案 »

  1.   

    用 obj.setAttribute("class" ,"imgover") 这样就可以
      

  2.   


    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    <HTML>
     <HEAD>
      <TITLE> New Document </TITLE>
      <style>
      .imgover{opacity=0.5;filter:alpha(opacity=50)}
      .imgout{opacity=1;filter:alpha(opacity=100)}  </style>
      <SCRIPT LANGUAGE="JavaScript">
      function doover(obj)
    {   obj.className="imgover"; //不起作用
     
    }
     function doout(obj)
    {   obj.className="imgout"; //不起作用
     
    }  </SCRIPT>
     </HEAD> <BODY>
      <img src="http://list.mp3.baidu.com/list/images/tupic/funny_egaosucai04.jpg"onmouseover="doover(this);" onmouseout="doout(this);" />
     </BODY>
    </HTML>
      

  3.   

    楼主imgbover名称都能写错
      

  4.   


    为什么 ie ok ff 不起作用?
    <html><head><title></title>
    <style type ="text/css">
    #box{ 
    width : 100px ; 
    height : 100px ;
    position : absolute ;
    left : 50px ;
    bottom : 50px ;
    }
    a:link {color: yellow}
    a:visited {color: red}
    a:hover {color: green}
    a:active {color: blue}
    #imga {opacity:0.5;filter:alpha(opacity=50)}.imgover{opacity=0.5;filter:alpha(opacity=50)}
    .imgout{opacity=1;filter:alpha(opacity=100)}
    </style>
    <script>
    function doover(obj)
    {  obj.className="imgover";
    }
    function doout(obj)
    {obj.className="imgout";}
    </script>
    </head><body>
    <div id="box">
    <a href="http://www.gruden.com" target="_blank">This is my link.</a>
    <img id="imga" alt="gruden" src="http://www.gruden.com/images/gruden_logo.gif" /> 
    <!--<img id="imgb" alt="gruden" src="http://www.gruden.com/images/gruden_logo.gif" onmouseover="this.style.opacity=0.5;this.filters.alpha.opacity=50"
    onmouseout="this.style.opacity=1;this.filters.alpha.opacity=100"  /> -->
    <img id="imgb" alt="gruden" src="http://www.gruden.com/images/gruden_logo.gif" onmouseover="doover(this);" onmouseout="doout(this);" />
      </div>
    </body></html>
      

  5.   

    if(document.all) 
      obj.setAttribute("className",strStyle);
    else
      obj.setAttribute("class",strStyle);
      

  6.   

    在FireFox里是这么写的:style = " -moz-opacity:0.8;"或者#divobj{
    -moz-opacity:0.8; 
    }下面这样就兼容IE和FF了:
    divobj{
    filter = alpha(opacity=580);
    -moz-opacity = 0.5; 
    }
      

  7.   

    filter:alpha(opacity=50); /* IE */ ; -moz-opacity:0.5; /* Moz + FF */ ; opacity: 0.5; /* 支持CSS3的浏览器(FF 1.5也支持)*/">