複製程式碼 程式碼如下: 无标题文档 <br> #div1{width:100px;height:100px;background:#ccc;position:absolute;top:0px;left:0px;}<br> #div2{width:100px;height:100px;background:#ccc;position:absolute;left:0px;top:110px;}<br> #div3{width:100px;height:100px;background:red;position:absolute;left:220px;top:0px;filter:alpha(opacity:30);opacity:0.3;}<br> #div4{width:100px;height:100px;background:red;position:absolute;left:330px;top:0px;filter:alpha(opacity:30);opacity:0.3;}<br> #div5{width:100px;height:100px;background:red;position:absolute;left:440px;top:0px;filter:alpha(opacity:30);opacity:0.3;}<br><br>window.onload=function()<br>{ <br> oDiv1=document.getElementById("div1");<br> oDiv2=document.getElementById("div2");<br> oDiv3=document.getElementById("div3");<br> oDiv4=document.getElementById("div4");<br> oDiv5=document.getElementById("div5"); <p> oDiv1.onmouseover=function(){<br> Move(oDiv1,"width",200); <br> //alert(getStyle(oDiv1,"width"));<br> }<br> oDiv1.onmouseout=function(){<br> Move(oDiv1,"width",100);<br> }<br> oDiv2.onmouseover=function(){<br> Move(oDiv2,"height",200); <br> }<br> oDiv2.onmouseout=function(){<br> Move(oDiv2,"height",100);<br> }<br> oDiv3.onmouseover=function(){<br> Move(oDiv3,"opacity",100);<br> }<br> oDiv3.onmouseout=function(){<br> Move(oDiv3,"opacity",30);<br> }</p> <p> oDiv4.onmouseover=function(){<br> Move(oDiv4,"opacity",100); 🎜> Move(oDiv4,"opacity" ,30);<br> }<br> oDiv5.onmouseover=function(){<br> Move(oDiv5,"opacity",1000); out=function(){<br> Move(oDiv5,"opacity",30);<br> }<br><br> <br>} //getStyle 非行間屬性 結果值為***px <br> { if(obj.currentStyle)<br> {<br> }<br> else{<br> return getComputedStyle(obj, false)[attr];<br> } <br> } <br> /多物件不同物件不同動作框架 { <br> clearInterval(obj.timer); <br> obj.timer=setInterval(function(){<br> if(attr=="opacity")<com tyle> speed=(itarget -cur)/10;<br> speed=speed>0?Math.ceil(speed):Math.floor(speed); {<br> (obj.timer);<br> }else<br> { cur =speed;<br> obj.style.opacity=cur/100;<br> obj.style.filter="alpha(opacity:" cur ") "; <br> }<br> else<br> attr));<br> speed=(itarget-cur)/10; //parseInt 獲取的值轉換為數<br> if(cur==itarget)<br> {<br> }else<br> {<br> obj.style[attr]=cur 速度 "px"; <br> } <br> } <br><br> },30) <br> } <br> 变宽 变高