為什么不顯示透明呢 ?麻煩幫我看下!謝謝
<!DOCTYPE HTML>
<html>
<head>
? ? <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
? ? <title>無(wú)標(biāo)題文檔</title>
? ? <style type="text/css">
? ?body,div{
margin:0;
padding:0;
}
? ? ? ? #div1{
width:200px;
height:200px;
background-color:red;
filter:alpha(opacity:30);//透明度30
opacity:0.3;
}
</style>
? ? <script type="text/jscript">
window.onload=function(){
var oDiv=document.getElementById("div1");
//鼠標(biāo)移入透明度100
oDiv.onmouseover=function(){
starMove(100);
}
//鼠標(biāo)移出透明度30
oDiv.onmouseout=function(){
starMove(30);
}
? ? }
var timer=null;
var alpha=30;
function starMove(iTaget){
var oDiv=document.getElementById("div1");
clearInterval(timer);
timer=setInterval(function(){
var speed=0;//變量初始值為0;
if(alpha>=iTaget){
speed=-10;
}
else{
speed=10;
}
if(alpha==iTaget){
clearInterval(timer);
}
else{
alpha+=speed;
odiv.style.filter="alpha(opacity:‘+alpha+')";
oDiv.style.opacity=alpha/100;
}
},30)
}
</script>
</head>
<body>
<div id="div1"></div>
</body>
</html>
2016-01-11
2016-03-01
oDiv.style.filter = "alpha(opacity:" + alpha + ")";
2016-01-25
oDiv.style.filter="alpha(opacity:'+alpha+')"; odiv改成oDiv,opacity:'+alpha+'前面的那個(gè)引號(hào)號(hào)要切換英文輸入引號(hào)
2016-01-11
odiv.style.filter="alpha(opacity:‘+alpha+')";應(yīng)該是oDiv吧大小寫
<script type="text/jscript">應(yīng)該是<script?type="text/javascript">?