用一个计时器,修改style的透明属性

解决方案 »

  1.   

    曾经写过一个例子,你可以作为参考
    <!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=utf-8" />
    <title>Untitled Document</title>
    <style type="text/css">
    <!--
    #Layer1 {
    position:absolute;
    width:200px;
    height:115px;
    z-index:1;
    left: 8px;
    top: 9px;
    }
    #Layer1 {
    filter: Alpha(Opacity=0);
    }
    -->
    </style>
    <script language="javascript">
    var c = 0;

    var a = window.setInterval("setOpacity()",100);

    function setOpacity()
    {
    var lay1 = document.getElementById("Layer1");
    lay1.filters.item("Alpha").Opacity += 10;
    c++;

    if(c == 10)
    {
    clearInterval(a);
    }
    }
    </script>
    </head><body>
    <div id="Layer1" style="background-color:#00CC99">adfasdfasdfasdfasdf</div>
    <br />
    <br />
    <br />
    <br />
    <br />
    <br />
    <br />
    <br />
    <br />
    <br />
    <input type="button" value="test" onclick="setOpacity();" />
    </body>
    </html>
      

  2.   

    memoriccell(记忆细胞) 非常感谢阿!!!