JQuery scrollTop values fadeIn/Out
I have this code so that my '.button' would fadeIn if the 'scrollTop > 200'.
$(document).ready(function() {
$(window).scroll(function() {
if ($(this).scrollTop() > 200) {
$('.button').fadeIn(500);
} else {
$('.button').fadeOut(500);
}
});
});
What I want to happen is I want '.button' to fadeIn if it's on a certain
part of the page, and fadeOut if it's out of the specified part. For
example:
$(document).ready(function() {
$(window).scroll(function() {
if ($(this).scrollTop() 200 - 500) {
$('.button').fadeIn(500);
} else {
$('.button').fadeOut(500);
}
});
});
Basically, I want ".button" to disappear if it's outside of the values given.
No comments:
Post a Comment