我試圖爲圖像製作一個燈箱。我有下一個和上一個按鈕,他們正在工作。現在我試着用我現有的代碼,使幻燈片放映按鍵......這是可能使幻燈片播放和使用我的代碼暫停按鈕...這裏是我的代碼...如何在JavaScript中製作幻燈片放映按鈕?
var current_index = 0 // Our current index and total_images is the array variable containing images path
function Next() // Call to go to the next image
{
// If we're at the last index, go to zero, else go to the next index
current_index = (current_index === (total_images.length - 1) ? 0 : current_index + 1);
UpdateImage(); // Call update
}
function Previous() // Call to go to the previous image
{
// If we're at the first index (0), go to the last, otherwise go to the previous index
current_index = (current_index === 0 ? (total_images.length - 1) : current_index - 1);
UpdateImage(); // Call update
}
function UpdateImage() // Call to update the image element
{
document.getElementById('imgFull').src = total_images[current_index]; // Self explaining
}function Play()
{
var runSlideShow = setInterval(Next, 3000);
}
function Stop()
{
window.clearInterval(runSlideShow);
}
http://caroufredsel.dev7studios.com/這是有用的 – MarshalSHI
它沒有用......你有沒有其他的方式..? –