2017-03-02 60 views
0

我發現了一段jQuery代碼,我已經操縱它在我正在處理的項目中工作。背景圖片推子 - 第一張圖片之前的延遲

我的主要問題是,我設置延遲時間越長,第一張幻燈片所需的時間就越長。延遲設置爲「5000」,因此加載第一張幻燈片需要5秒,而我只是獲得白色背景,是否需要調整某些內容才能顯示加載後的第一張幻燈片。

FIDDLE

function cycleBackgrounds() { 
var index = 0; 

$imageEls = $('.imageCon .slide'); // Get the images to be cycled. 

setInterval(function() { 
    // Get the next index. If at end, restart to the beginning. 
    index = index + 1 < $imageEls.length ? index + 1 : 0; 

    // Show the next 
    $imageEls.eq(index).addClass('showImg'); 

    // Hide the previous 
    $imageEls.eq(index - 1).removeClass('showImg'); 
}, 5000); 
}; 

// Document Ready. 
$(function() { 
cycleBackgrounds(); 
}); 
+1

只是給起始圖像一類'showImg'不起作用? –

+1

在這裏,我在看代碼,而不是明顯的,有時你需要第二套眼睛,謝謝你的工作。 – webmonkey237

+0

很高興聽到它。有時候我需要第三套。乾杯。 –

回答

0

我意識到,我並沒有對第一個圖像主動DIV類。