Restarting a setInterval() in Javascript/jQuery (without clearInterval) -


i'm working on ui tabs built using jquery. works except 1 issue - did setinterval runs function trigger("click") goes next tab after 5000 miliseconds. runs through each tab fine, issue if user manually clicks on tab, timer setinterval not restart @ 0. example if user start on tab1 @ 0 miliseconds , clicks on tab2 @ 2000 miliseconds, setinterval doesn't go 0, start @ 2000 , run 5000 miliseconds , subsequently goto tab3. understand why it's happening, wonder if there way restart setinterval timing without having clearinterval() , creating entirely new setinterval(). insight appreciated.

update

thanks replies - reason trying avoid using clearinterval because having issues of how write code in way clearinterval stop setinterval completely. code setup track whenever user has clicked tab. problem auto change function utilizes trigger('click'), runs clearinterval function wrote when tabs auto-change. seems run fine on own, once user starts clicking on tabs, setinterval behaves unusually , switches tabs unpredictably. suspect happening several setintervals running @ once... here's code (if haven't guessed already, i'm pretty new @ javascript/jquery). i've commented out parts it's functional, still doesn't function intended (from first post).

// auto change tabs             if( options.interval ) {                  function timercom() {                     if( !$(".controller").hasclass('paused') ) {                         var = $(".tab-current > a").attr("rel");                         //alert(i);                         if( == 3 ) {i = 0};                         $container                             .find('a')                             .eq(i)                             .trigger('click');                     }                     }                  //$("#promo-items > li > a").click(function () {                     //var timer;                     //if( timer != null ) {clearinterval(timer);}                     timer = setinterval(timercom, options.interval);                  //});              } 

no, there no way restart timer set setinterval without clearing timer.


Comments

Popular posts from this blog

asp.net - repeatedly call AddImageUrl(url) to assemble pdf document -

java - Android recognize cell phone with keyboard or not? -

iphone - How would you achieve a LED Scrolling effect? -