Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript jQuery run function in a loop?

  • This topic is empty.
Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #38764

    Hi i’m wondering how to run a function repetedly for an infinite ammount of time, basically i’m trying to achieve “autoplay” with this function.

    $.fn.play = function(){
    var options = $.extend($.fn.qslider.defaultsSetting,$.fn.qslider.options);
    $('.qS-scene').each(function(index){
    $('img', this).delay(options.sceneDuration*index+options.scenePause).each(function(index){
    $(this).delay(options.itemDelay*index).each($.fn.moveIn)
    })
    })
    }

    I could make a separate function if it helps, if you want to see it in action (i’m not good @ describing) go here:

    #105335
    TheDoc
    Member

    You could use setInterval, but I’m sure some smarter people would explain to you why it’s not good and there’s something better.

    Here’s some more reading on it: http://wallofscribbles.com/2011/setinterval-the-sneaky-basterd-child-of-javascript/

    #105336
    karlpcrowley
    Participant

    I’d use the setTimeout instead

    x
    function yourFunction() {
    // content of yourFunction
    setTimeout("yourFunction()", speed);
    }
    yourFunction();
Viewing 3 posts - 1 through 3 (of 3 total)
  • The forum ‘JavaScript’ is closed to new topics and replies.