Search code examples
jqueryanimationslideupsequential

Execute animations sequentially instead of simulatenously using class selector


Self admitted newbie here, hope this will be a simple solution.

$(.classname).slideUp();

When I execute the above code, all of the elements slide up at the same time. Instead, I would like them to perform the animation one after another.

Any help? Thanks!


Solution

  • Try this:

    var animInterval = 100; // 100ms interval between animation starts
    $('.className').each(function (i, e) {
        setTimeout(function () {
            $(e).slideUp();
        },i * animInterval);
    });