基本上我需要縮略圖來旋轉每次用戶懸停在圖像上。這是我的失敗嘗試:如何在jQuery中創建旋轉的縮略圖功能?
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js"></script>
<script type="text/javascript">
$(function() {
$('img').hover(function() {
theImage = $(this).attr('id');
otherImages = $(this).attr('class').split('@');
rotateThumbs(otherImages, theImage);
}, function() {
//
});
});
function rotateThumbs(otherImages, theImage) {
for (i=0; i < otherImages.length; i++) {
setInterval($('#'+theImage).attr('src', otherImages[i]), 1000);
}
}
</script>
<img id="myImage" src="http://www.google.com/images/logos/ps_logo2.png" class="http://www.google.com/images/logos/[email protected]://l.yimg.com/a/i/ww/met/[email protected]://dogandcat.com/images/cat2.jpg" width="174" height="130" />
有沒有人知道這可能是如何完成的?
當然,他們不能在互聯網上的jQuery圖像/縮略圖旋轉庫的短缺,可以用作例子? – 2011-06-16 22:07:22
這不是'setInterval'應該如何調用。 – Blindy 2011-06-16 22:07:58
你想做什麼?每次圖像懸停時,請切換到下一張圖像?或者,當圖像懸停時,顯示每個圖像一秒鐘,然後移動到下一個? – gilly3 2011-06-16 22:14:26