javascript - Select every 3 elements with jQuery and add animation delay to them starting from iteration count -


i want add animation delay starting 0 3 elements example below:

<div style="animation-delay: 0s;"></div> <div style="animation-delay: .25s;"></div> <div style="animation-delay: .5s;"></div> <div style="animation-delay: 0s;"></div> <div style="animation-delay: .25s;"></div> <div style="animation-delay: .5s;"></div> <div style="animation-delay: 0s;"></div> <div style="animation-delay: .25s;"></div> <div style="animation-delay: .5s;"></div> 

what doing right now:

var eventcards = $('.upcoming-events').find('.event-card'); eventcards.each(function(i, el){     if( % 3 == 0 ) {         $(this).css({             '-webkit-animation-delay': '.25' * + 's',             '-moz-animation-delay': '.25' * + 's',             '-o-animation-delay': '.25' * + 's',             'animation-delay': '.25' * + 's'         });     } }); 

with if add delay on each third element. if want exact result first example change code to:

eventcards.each(function(i, el){     var j = % 3;         $(this).css({             '-webkit-animation-delay': '.25' * j + 's',             '-moz-animation-delay': '.25' * j + 's',             '-o-animation-delay': '.25' * j + 's',             'animation-delay': '.25' * j + 's'         }); }); 

here codepen


Comments

Popular posts from this blog

angular - Ionic slides - dynamically add slides before and after -

minify - Minimizing css files -

Add a dynamic header in angular 2 http provider -