2013-04-16 80 views
0

目前,我有這個,但它一直返回「swapBKgnd是沒有定義」:jQuery如何正確設置間隔?

var interval = self.setInterval("swapBKgnd()", 9000); 

function swapBKgnd() { 

    (direction === 'next') ? ++current : --current; 

    if (current === 0) { 
     current = imgsLenth; 
     direction = 'next'; 
    } else if (current - 1 === imgsLenth) { 
     current = 1; 
     loc = 0; 
    } 


    transition(sliderUL, loc, direction); 
}; 

感謝。

+0

嘗試function' :) –

+2

變種的時間間隔後'申報'VAR interval' =的setInterval( swapBKgnd,9000); –

+0

刪除'swapBKgnd()'中的引號。 – karthikr

回答

0

刪除swapBKgnd()的報價。

使用可以這樣做:

var interval = self.setInterval(swapBKgnd, 9000); 

您還沒有宣佈directioncurrentloc - 那些會引發錯誤

+0

「var interval = self.setInterval(swapBKgnd(),9000);」這是錯誤的,「var interval = self.setInterval(」swapBKgnd「,9000);」也是錯誤的 –

+0

這個工程..錯誤是'方向'undefined – karthikr

+0

我沒有發佈整個腳本。這些在前面定義。 – Kennyist