window.onload = function() {
var div1 = document.getElementById(‘div1‘);
div1.onmouseover = function(){
startMove(this,400);
}
div1.onmouseout = function(){
startMove(this,200);
}
function startMove(obj, iTarget) {
clearInterval(obj.timer);
obj.timer = setInterval(
function() {
var speed = (iTarget-obj.offsetHeight)/3;
obj.style.height = obj.offsetHeight + speed + ‘px‘;
obj.style.width = obj.offsetWidth + speed + ‘px‘;
}, 30)
};
}
时间: 2024-10-10 12:14:21