I’m trying to apply a class to a div only when the window top is between 500 and 900 pixels but not before or after. Is this possible?
My current code only works for past 500px:
if($(this).scrollTop() >= 500) {
$('#01').addClass('selected');
} else {
$('#01').removeClass('selected');
}
Is it possible to have something this?:
if($(this).scrollTop() >= 500 <= 900) {
$('#01').addClass('selected');
} else {
$('#01').removeClass('selected');
}
Thanks!
and I must admit I am curious as to how you checking said position. What event are you binding this logic to?