<! DOCTYPE html>
<meta http-equiv= "Content-type" content= "text/html; Charset=utf-8 "/>
<title> Untitled Document </title>
<font face= "Verdana, Geneva, Sans-serif" ></font>
<style type= "Text/css" >
#div1 {width:100px;height:100px;background: #ccc;p osition:absolute;top:0px;left:0px;}
#div2 {width:100px;height:100px;background: #ccc;p osition:absolute;left:0px;top:110px;}
#div3 {width:100px;height:100px;background:red;position:absolute;left:220px;top:0px;filter:alpha (opacity:30); o pacity:0.3;}
#div4 {width:100px;height:100px;background:red;position:absolute;left:330px;top:0px;filter:alpha (opacity:30); o pacity:0.3;}
#div5 {width:100px;height:100px;background:red;position:absolute;left:440px;top:0px;filter:alpha (opacity:30); o pacity:0.3;}
</style>
<script type= "Text/javascript" >
Window.onload=function ()
{
Odiv1=document.getelementbyid ("Div1");
Odiv2=document.getelementbyid ("Div2");
Odiv3=document.getelementbyid ("Div3");
Odiv4=document.getelementbyid ("Div4");
Odiv5=document.getelementbyid ("div5");
Odiv1.onmouseover=function () {
Move (ODIV1, "width", 200);
Alert (GetStyle (ODIV1, "width"));
}
Odiv1.onmouseout=function () {
Move (ODIV1, "width", 100);
}
Odiv2.onmouseover=function () {
Move (ODiv2, "height", 200);
}
Odiv2.onmouseout=function () {
Move (ODiv2, "height", 100);
}
Odiv3.onmouseover=function () {
Move (ODiv3, "opacity", 100);
}
Odiv3.onmouseout=function () {
Move (ODiv3, "opacity", 30);
}
Odiv4.onmouseover=function () {
Move (ODIV4, "opacity", 100);
}
Odiv4.onmouseout=function () {
Move (ODIV4, "opacity", 30);
}
Odiv5.onmouseover=function () {
Move (ODIV5, "opacity", 100);
}
Odiv5.onmouseout=function () {
Move (ODIV5, "opacity", 30);
}
}
Get style between rows
function GetStyle (obj,attr)//getstyle non-row property result value is ***PX
{if (Obj.currentstyle)
{
return obj.currentstyle[attr];
}
else{
Return getComputedStyle (Obj,false) [attr];
}
}
Multi-Object different motion frame
function Move (obj,attr,itarget)
{
Clearinterval (Obj.timer);
Obj.timer=setinterval (function () {
if (attr== "opacity")
{Cur=parsefloat (GetStyle (obj,attr)) *100;
Speed= (itarget-cur)/10;
Speed=speed>0? Math.ceil (Speed): Math.floor (speed);
if (cur==itarget)
{
Clearinterval (Obj.timer);
}else
{cur+=speed;
obj.style.opacity=cur/100;
Obj.style.filter= "Alpha (opacity:" +cur+ ")";
}
}
Else
{
Cur=parseint (GetStyle (obj,attr));
Speed= (itarget-cur)/10; Parseint the value obtained is converted to a number
Speed=speed>0? Math.ceil (Speed): Math.floor (speed); Downward, up positive
if (cur==itarget)
{
Clearinterval (Obj.timer);
}else
{
obj.style[attr]=cur+speed+ "px";
}
}
},30)
}
</script>
<body>
<div id= "Div1" > Widening </div>
<div id= "Div2" > High </div>
<div id= "Div3" ></div>
<div id= "Div4" ></div>
<div id= "DIV5" ></div>
</body>