Following function reveals <li> elements one by one from left to right.
$.fn.fadeInEach = function(duration,callback){
function fadeIn(i,elements,duration,callback){
if(i >= elements.length)
typeof callback == 'function' && callback();
else
elements.eq(i).fadeIn(duration,function(){
fadeIn(i+1,elements,duration,callback);
});
}
fadeIn(0,this,duration,callback);
return this;
}
Executing like that
$('.ftr-social-icons ul li').fadeInEach(200);
Lets say we have 9 <li> elements. What I want to get is, first reveal 5th element, then 4th and 6th, then 3th and 7th…
If there is 8 <li> elements, reveal at first 4th and 5th, and so on…
Any suggestions?
Here’s a plugin example. Does this help?
HTML:
JavaScript: