为什么没有反应?

<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>relative样式</title>
<style type="text/css">

        #div1{

            width: 200px;

            height: 200px;

            background: red;

            opacity: 0.3;

            filter:alpha(opacity:30);

        }

   
  


</style>
<script type="text/javascript">
window.onload=function(){
 var oDiv=document.getElementById("div1")
 oDiv.onmouseover=function(){
  startMove(100)
 }
 oDiv.onmouseout=function(){
     startMove(30)
 }
}

var timer=null
var alpha=30
function startMove(b){
 clearInterval(timer)
var oDiv=document.getElementById("div1")
 timer=setInterval(function(){
   var a=0
   if(alpha>b){
    a=-10
   }
   else{
    a=10                                        
   }
 
 
  if(alpha==b){
 clearInterval(timer)
  }
  else{
  alpha+=a
  oDiv.style.filter='alpha(opacity:'+alpha+')'
  oDiv.style.opacity=alpha/100
 },30)
}

</script>
</head>
<body>
 <div id="div1"></div>
</body>
</html>

慕先生0450854
浏览 1233回答 1
1回答
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

JavaScript