做的淡入淡出怎么不能实现效果啊 浏览器也没报错

<!doctype html>

<html>

<head>

<meta charset="UTF-8">

<title>Document</title>

<style type="text/css">

              #box{width: 300px;height: 300px;background: red;

                        opacity: 0.3;

                        filter:alpha(opacity: 30)}

</style>

<script type="text/javascript">

             window.onload=function()

             {

                var Box=document.getElementById('box')

                Box.onmouseover=function()

                {

                 startMove(100) 

                }  

                Box.onmouseout=function()

                {

                 startMove(30) 

                }                   

             }

             var timer=null;

              var alpha=30

             function startMove(Target)             

             {                                     

              var Box=document.getElementById('box')

              clearInterval(timer)

              timer=setInterval(function()

               { 

                                  var speed=0

                       if(alpha<Target)

                       {

                                          spend=10

                       }


                       else

                       {

                        spend=-10

                       }

                       if(alpha==Target)

                       {

                        clearInterval(timer)

                       }

                       else

                       {

                        alpha+=speed

                        Box.style.opacity=alpha/100;

                        Box.style.filter='alpha(opacity:'+alpha+')'


                       }


               },30)

             }

</script>

</head>

<body>

<div id="box">


</div>


</body>

</html>


慕粉4084340
浏览 1470回答 2
2回答

stone310

中间speed赋值写成spend了..
打开App,查看更多内容
随时随地看视频慕课网APP