I have a div element #btns
that is hidden by default. It should be displayed on scrolling 200px
from top and again hidden after 500px
from top.
Here is my (non-working) code:
$(window).scroll(function() {
if ($(this).scrollTop()>200) {
$('#btns').fadeIn();
}
elseif ($(this).scrollTop()<500) {
$('#btns').fadeIn();
} else {
$('#btns').fadeOut();
}
});
You can add a class hide in button like this:
DEMO https://jsfiddle.net/1ks8at6r/5/