2014-02-28 66 views
0

我正在嘗試使用prev和next按鈕製作一個簡單的滑塊。滑塊工作正常,接下來的按鍵功能正常的,但你可以看到上一個按鈕是靠不住的:jQuery slider next prev button issue

invNext.on('click', function PreviousPic() { 

    var currentPic = $('.img-nav-container > img'); 
    $(currentPic).fadeOut(1000, function() { 

    // fadeIn the previous image in the array 
    var img = imgArr[(currIndex - 1)]; // not working 
    $("#slider").attr("src", img); 
    GetNewImage(); 
    $("#slider").fadeIn(1000); 

    }); 

http://jsfiddle.net/davidpm/5TsL6/

我做了一個的jsfiddle,因爲它會更有幫助看到的一切多數民衆贊成回事。 我錯過了什麼?此外,我會很感激任何幫助重構這個混亂。我還是一個很有用jQuery新手...

在此先感謝,

-D

回答

0

試試這個,

invNext.on('click', function PreviousPic() { 

    var currentPic = $('.img-nav-container > img'); 
    $(currentPic).fadeOut(1000, function() { 

    // fadeIn the previous image in the array 
    var img = imgArr[(currIndex - 2)]; // not working 
    $("#slider").attr("src", img); 
    GetNewImage(); 
    $("#slider").fadeIn(1000); 

    }); 
+0

哎HB,我想已經沒有運氣,我甚至現在就放棄了它,但它仍然不起作用。它只是不斷重新加載相同的圖像。 – davidpm4