这个脚本有问题,不能让它在最后一张图片之后继续旋转拇指
var cdn_url = 'http://cdn.domain.com/';
var timers = new Array;
var images = new Array;
function changeThumb( id, cdn_url )
{
document.getElementById(id).src = cdn_url;
}
$(document).ready(function() {
$("img[id*='tmb_']").mouseover(function(){
var image_id = $(this).attr("id");
var id_split = image_id.split('_');
var one = id_split[1];
var two = id_split[2];
thumbs = 10;
for ( var i=0; i<=thumbs; i++ ) {
var image_url = cdn_url + one + '/' + two + '/' + i + '.jpg';
images[i] = new Image();
images[i].src = image_url;
}
for ( var i=0; i<=thumbs; i++ ) {
timers[i] = setTimeout("changeThumb('" + image_id + "','" + cdn_url + one + '/' + two + '/' + i + '.jpg' + "')", i*200);
}
}).mouseout(function(){
var image_id = $(this).attr("id");
var id_split = image_id.split('_');
var one = id_split[1];
var two = id_split[2];
var init = id_split[3];
thumbs = 10;
for ( var i=0; i<=thumbs; i++ ) {
if ( typeof timers[i] == "number" ) {
clearTimeout(timers[i]);
}
}
$(this).attr('src', cdn_url + one + '/' + two + '/' + init + '.jpg');
});
});
html
<img id="tmb_0613_2913374229_4" class="img" src="http://cdn.domain.com/thumbs/0613/2913374229/4.jpg" />
拇指在悬停时旋转,但在最后(10.jpg)之后不会从 0.jpg 重新开始