我一直试图解决这个问题,但现在我想我会把它贴在这里,看看我是否最终能理解setInterval
我遇到的这个问题。
如果这很重要,我在本文档中使用 jQuery 1.4.4。
鉴于以下情况:
var MS = {},
MS.timer = 1200; // this both would be user accessible by the plugin
// if the timer option is set then activate slideshow
if ( MS.timer ) { setInterval( "go(2,'right')" , MS.timer); }
// show the slide (as defined by the pass ins)
function go(slideNumber, direction) {
if ( !paused || !running ) {
console.log('run!'+', '+slideNumber+' , '+direction);
}
}
然而,这会导致:
go is not defined
每 1200 毫秒“正确”记录一次。那么如何运行我的函数go()
,包括传入的值slideNumber, direction
?