window.onload = function () {
var clist= document.getElementById('courselist');
var cimg = clist.getElementsByTagName('img');
var cwidth = 280;
var cheight = 160;
var marginLeft = 0;
var marginTop = 0;
var startTimer = null;
var outTimer = null;
for(var i=0;i<cimg.length;i++){
cimg[i].index=i;
cimg[i].onmouseover = function(){
clearInterval(outTimer);
startTimer=setInterval(function (){
cwidth = cwidth + 2;
cheight = cheight + 1;
marginLeft = marginLeft - 1;
marginTop = marginTop - 0.5;
cimg[this.index].style.width = cwidth+'px';
cimg[this.index].style.height = cheight+'px';
cimg[this.index].style.marginLeft = marginLeft+'px';
cimg[this.index].style.marginTop = marginTop+'px';
if (cwidth>380) {
clearInterval(startTimer);
};
},20);
}
cimg[i].onmouseout = function () {
clearInterval(startTimer);
outTimer = setInterval(function () {
cwidth= cwidth - 2;
cheight = cheight - 1;
marginLeft = marginLeft + 1;
marginTop = marginTop + 0.5;
cimg[this.index].style.width = cwidth+'px';
cimg[this.index].style.height = cheight+'px';
cimg[this.index].style.marginLeft = marginLeft+'px';
cimg[this.index].style.marginTop = marginTop+'px';
if (cwidth<=280) {
clearInterval(outTimer);
};
},20);
}
}
}
木可不可
相关分类