透明度沒有變化,請(qǐng)大神指教
<!DOCTYPE?HTML> <html> <head> <meta?http-equiv="Content-Type";content="text/html";charset="utf-8"/> <title>透明度的改變</title> <style?type="text/css"> *{ margin:0; padding:0; } #did{ width:200px; height:200px; background:red; filter:alpha(opacity:30); ????????????opacity:0.3; margin:auto; } </style> <script?type="text/JavaScript"> window.load=function(){ var?oDiv?=?document.getElementById("did"); oDiv.onmouseover=function(){ startChange(100); } oDiv.onmouseout=function(){ startChange(30); } } var?timer?=?null; var?speed?=?0; var?alpha?=?30; function?startChange(itarget){ var?oDiv?=?document.getElementById("did"); clearInterval(timer); timer?=?serInterval(function(){ if(alpha>itarget){ speed?=?-10; } else{ speed?=?10; } if(alpha?==?itarget){ clearInterval(timer); } else{ alpha?+=?speed; oDiv.style.filter?=?'alpha(opacity:'+alpha+')'; oDiv.style.opacity?=?alpha/100; } },30) } </script> </head> <body> <div?id="did"></div> </body> </html>
找了好久的錯(cuò)誤,都沒有找到,眼已瞎,求大神看看!1
2016-11-26
1、window.onload寫錯(cuò)
2、setInterval寫錯(cuò)