Create a Javascript function from this jQuery snippet? -


i have following code, working, i'd "automatize" javascript function, won't have write on , on again.

$("#portfolio").waypoint(function() {      $('.portfolio-item').eq(0).css("animation-delay","0.0s");     $('.portfolio-item').eq(1).css("animation-delay","0.3s");        $('.portfolio-item').eq(2).css("animation-delay","0.6s");     $('.portfolio-item').eq(3).css("animation-delay","0.9s");     $('.portfolio-item').eq(4).css("animation-delay","1.2s");     $('.portfolio-item').eq(5).css("animation-delay","1.5s");     $('.portfolio-item').eq(6).css("animation-delay","1.8s");     $('.portfolio-item').eq(7).css("animation-delay","2.1s");     $('.portfolio-item').eq(8).css("animation-delay","2.4s");      $('.portfolio-item').addclass('animated fadeinup');   }, { offset: 400});  

thanks!

an alternative sidcool's answer use jquery each prevent using eq :

$('#portfolio').waypoint(function(){     var $items=$('.portfolio-item');     $items.each(function(i){         $(this).css('animation-delay', (i*0.3)+"s");     });     $items.addclass('animated fadeinup'); }, {offset: 400}); 

though, realized suggested earlier. credits him :-)


Comments

Popular posts from this blog

php - Calling a template part from a post -

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -