2013-04-16 82 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