为什么没效果呢
<!doctype html> <html> <head> <meta charset="utf-8"> <title>无标题文档</title> <style type="text/css"> body {margin:0;} .divs { width:200px; height:200px; background: red; opacity:0.3; filter:alpha(opacity:30); cursor:pointer; } </style> <script type="text/javascript"> window.onload = function(){ var timer = null; var apa = 30; var oDiv=document.getElementsByClassName("divs")[0]; function Alphas (iTarget){ clearInterval(timer); var Speed = 0; if(iTarget>apa){ Speed = 10; }else if(iTarget<apa){ Speed = -10; } timer = setInterval(function(){ if(apa ==iTarget){ clearInterval(timer) }else{ apa+=Speed; oDiv.style.opacity = apa/100; oDiv.style.filter="alpha(opacity:"+apa+")"; //console.log(apa); } },20) oDiv.onmouseover=function(){ Alphas(100); } oDiv.onmouseout=function(){ Alphas(30); } } } </script> </head> <body> <div class="divs"></div> </body> </html>
为什么移入移出都没效果呢?怎么也找不到问题在哪 也不报错