I'm trying to fadeIn and fadeOut list items individually by scrolling every 100 pixels down or up respectively.
$(document).scroll(function() {
var top = $(document).scrollTop();
for (var heightForBanner = 400;heightForBanner<2000;heightForBanner+=100)
{
if (top > heightForBanner) $('.photobannerA5 ul li:nth-child(" + heightForBanner / 100 + ")').fadeIn('fast');
if (top < heightForBanner) $('.photobannerA5 ul li:nth-child(" + heightForBanner / 100 + ")').fadeOut('fast');
}
by looping through the value of scrolled pixels and then assigning the value (divided by 100) to the 'nth-child'
The way I'm doing it doesn't work at all. Any idea what I'm doing wrong? Or maybe a completely different approach?
Thanks...