opacity 問題 無法運行 代碼和老師的一樣
<!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>普通速度動畫</title>
<style type="text/css">
*{margin:0;padding:0;}
div{width:100px;height:100px;background-color:#C00;position:relative;left:0px;top:0;opacity:0.3;filter:Alpha(opacity=30);}
</style>
<script type="text/javascript">
?window.onload=function(){
var mdiv=document.getElementById("wrapper"); ? ? ? ??
mdiv.onmouseover=function(){startmove(100)};
? ? ? ? ?mdiv.onmouseout=function(){startmove(30)}; ? ? ? ? ?
?}
var timer=null;
var alpha=30;
function startmove(itarget){
var mdiv=document.getElementById("wrapper");
clearInterval(timer);
timer=setInterval(function(){
var speed=0;
if(alpha>itarget){speed=-10;}
else{speed=10;}
if(alpha==iterget){clearInterval(timer)}
else{alpha+=speed;mdiv.style.opacity=alpha/100;mdiv.style.filter="Alpha(opacity:'+alpha+')"}
},30)
}
</script>
</head>
<body>
?<div id="wrapper">
? <span id="span">微信</span>
?</div>
</body>
</html>
2016-05-10
不好意思 ?自己已經(jīng)檢查出問題在哪了 ?最后的itarget拼寫錯誤了 ?哎 ?太粗心大意了?