0

So I have this object:

<span>Fadeout on scroll</span>

And this code:

$(window).scroll(function () { 
  $("span").fadeOut("slow");
});
  $("span").fadeIn("slow");

I want the object to fade out when scrolling, and fade back in when complete

My code doesn't work for what I need it to work for.

TaylorMac
  • 8,882
  • 21
  • 76
  • 104

1 Answers1

0

YNhat's link will describe how to do it correctly.

However, in case you want to know why yours doesn't work. If you look at your code, the fadeIn is completely outside of any event. This means that it will run initially when the browser interprets it and never again. The fadeOut will run every time you scroll but fadeIn will not run so it will just stay hidden.

James Montagne
  • 77,516
  • 14
  • 110
  • 130