I have a Object Orientated Content/Image Slider I’m working on.
I am having trouble with setInterval() just running once.
I’m passing a string value to my function cn.hero('','','','','',0,0,'yes'); which when matched should start triggering a click automatically.
Here is my code:
cn = {
hero:function(r,rc,lx,rx,fx,fs,ss,auto){
$(lx).click(...}
if(auto.match('yes')){ setInterval($(lx).click(),7000); }
}
}
$(function(){
cn.hero('#reel', '#reel div', '#reel-left', '#reel-right', 'slide', 300, 500, 'yes');
});
Any Help would be greatly appreciated, thanks
You need an anonymous function — what you have is executing immediately
When you pass code to
setIntervallikethe code is executed immediately; jQuery will parse that selector, and fire the click event right then and there.