Skip to content Skip to sidebar Skip to footer

How Can One Set A Sequential Delay On Adding A Class?

I'm using jQuery UI plugin and the latest jQuery. I would like to sequentially add on the class, one by one down my array of elements. Right now I have this : $(@el).addClass('grid

Solution 1:

delay() delays animations, not classname changes or other code executions. If you want generic execution delay, use setTimeout or something like:

$.fn.wait = function(ms, callback) {
  return this.each(function() {
    setTimeout(callback.bind(this), ms)
  })
}

$(@el).addClass("gridBoxComplete", 400, "easeOutBounce").wait(800, function() {
    $(this).addClass("something");
});

Post a Comment for "How Can One Set A Sequential Delay On Adding A Class?"