<!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=gb2312" />
<title>无标题文档</title>
<style type="text/css">
*{
margin:0;
padding:0;
}
div{
width:200px;
height:200px;
background:red;
margin:10px;
filter:alpha(0pacity:30);
opacity:0.3;
float:left;
}
</style>
<script>
window.onload=function(){
var a=document.getElementsByTagName('div');
for(var i=0;i<a.lengh;i++){
a[i].onmouseover=function(){
startmove(this,100);
}
a[i].onmouseout=function(){
startmove(this,30);
}
}
}
var alpha=30;
function startmove(obj,target){
clearInterval(obj.time);
obj.time=setInterval(function(){
var speed=0;
if(alpha>target){
speed=-10;
}
else{
speed=10;
}
if(alpha==target){
clearInterval(obj.time);
}
else{
alpha+=speed;
obj.style.opacity=alpha/100;
}
},30)
}
</script>
</head>
<body>
<div></div>
<div></div>
<div></div>
</body>
</html>
涼風有信
相关分类