h1 jQuery delay & queue sample
.container
.element
.element
.element
.element
View Compiled
@import url('https://fonts.googleapis.com/css?family=Roboto+Slab&display=swap');
body {
background: #333;
font-family: 'Roboto Slab', serif;
}
h1 {
text-align: center;
color: #fff;
margin-top: 80px;
letter-spacing: .05em;
}
button {
display: block;
margin: 0 auto;
}
.container {
display: flex;
justify-content: center;
padding: 40px 50px 120px;
}
.element {
width: 15vw;
height: 15vw;
border-radius: 50%;
background: #FFD05C;
margin: 16px;
opacity: 0;
transition: opacity 1s;
&.is-active {
opacity: 1;
}
}
View Compiled
const element = $('.element');
const delayTime = 300;
element.each(function (i) {
$(this).delay(i * delayTime).queue(()=> {
$(this).addClass('is-active').dequeue();
});
});
View Compiled
This Pen doesn't use any external CSS resources.