<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<style>
div{
width: 150px;
height: 150px;
background: red;
filter:alpha(opacity:30);
opacity: 0.3;
margin: 5px;
float: left;
}
</style>
<script>
window.onload = function(){
var mydiv = document.getElementTagName(‘div‘);
for(var i=0;i<mydiv.length;i++){
mydiv[i].timer = null;
mydiv[i].alpha = 30;
mydiv[i].onmouseover = function(){
starmove(this,100);
};
mydiv[i].onmouseout = function(){
starmove(this,30);
};
}
};
function starmove(obj,target){
clearInterval(obj.timer);
timer = setInterval(function(){
var speed = (target-obj.alpha)/6;
speed = speed>0?Math.ceil(speed):Math.floor(speed);
if(obj.alpha == target){
clearInterval(timer);
}else{
obj.alpha = obj.alpha + speed;
obj.style.filter = alpha(opacity:obj.alpha);
obj.style.filter = obj.alpha/100;
}
},30);
}
</script>
</head>
<body>
<div></div>
<div></div>
<div></div>
<div></div>
</body>
</html>