1

Is there a way to delay a change on CSS in jQuery?

Using this code, I manage to fade elements in one after another :

$(".crea-card").each(function(index) {
   $(this).delay(400*index).fadeIn(300);
});

But using this one, the CSS effects are all applied at the same time:

$(".crea-card").each(function(index) {
      $(this).delay(400*index).css('opacity', 1);
      $(this).delay(400*index).css('transform', 'translate(0,0)');
});

How can I delay them so that the opacity is set to 1 one after another?

(I know the CSS and jQuery don't behave the same)

1 Answer 1

3

Use it like this:

$(".crea-card").each(function(index) {
  .delay(800)
  .queue(function (next) { 
    $(this).css('opacity', 1); 
    $(this).css('transform', 'translate(0,0)');
    next(); 
  });
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.