我有兩個JS按鈕可以上下滾動,如 this sample page所示。使用JS滑動或捲起圖像使用JS
現在它只是改變圖像沒有效果,我需要應用滑動或滾動效果,使圖像看起來循環,像THIS但上下,
JS代碼被動態地從ASP生成。網頁, 這裏是JS長達按鈕,
var my_slots = ['_', 'x', 'y', 'z', '0', '1',
'2', '3', '4', '5', '6', '7', '8', '9'];
$("#sslot_img0_u").live('click', function() {
image = document.getElementById('sslot_img' + '0');
image.setAttribute('src', do_up('0', image.getAttribute('alt')));
$("#hstring").val(my_slots[2]);
return false;
});
function do_up(key1, key2) {
image = document.getElementById('sslot_img' + key1);
if (Number(key2) == my_slots.length - 1) {
image.setAttribute('alt', '0');
$get('sslot_hf' + key1).value = my_slots[0];
return "http://www.fedne.com/" + my_slots[0] + '.gif';
} else {
image.setAttribute('alt', (Number(key2) + 1));
$get('sslot_hf' + key1).value = my_slots[Number(key2) + 1];
return "http://www.fedne.com/" + my_slots[Number(key2) + 1] + '.gif';
}
}
,並有可能得到的按鈕不是在div單擊事件這種效果呢?
我會建議您使用單個圖像作爲數字微調而不是10個獨立的圖像。這將大大簡化動畫。 – Shmiddty
不錯的想法,但代碼中顯示的問題是,它是動態生成的,我使用'my_slots'數組來顯示顯示的數字。 – Alaa
使用單獨的圖像時,您必須:單擊箭頭時創建下一個數字,適當地爲當前數字和下一個數字設置動畫,然後銷燬第一個數字。希望有所幫助。 – Shmiddty