jquery - javascript onscroll fade same class but with different div -
i new @ javascript , want learn new.
there wrong code : why div
fades @ same time.
i want ask how fade different div
s same class
name.can me , explain me.
thanks in advance.
javascript:
$(window).scroll(function(){ if ($( "div.fade" ).offset().top - $(window).scrolltop() <= 100){ $('.fade').addclass( "fade-in"); } else { $('.fade').removeclass("fade-in"); } });
here jsfiddle
onscroll = function () { var scrolltop = $(this).scrolltop() ; $("div.fade").each(function(){ if(($(this).offset().top - scrolltop) <= 100){ $(this).toggleclass("fade-in"); } }) }
Comments
Post a Comment