I can scroll on the top or the bottom of my page. But after 5seconds, I want my scroll div disapear. I use the property delay & hide of Jquery. I must refresh my page to works my code once my div disapear.
$(function () {
var scrollTrigger = 100, // px
backToTop = function () {
var scrollTop = $(window).scrollTop();
if (scrollTop > scrollTrigger) {
$("a[href='#top']").addClass('show').delay(2000).hide(500);
$("a[href='#bottom']").addClass('show').delay(2000).hide(500);
} else {
$("a[href='#top']").removeClass('show');
$("a[href='#bottom']").removeClass('show');
}
};
backToTop();
$(window).on('scroll', function () {
backToTop();
});
$("a[href='#top']").click(function() {
$("html, body").animate({ scrollTop: 0 }, "slow");
return false;
});
$("a[href='#bottom']").click(function() {
$('html,body').animate({ scrollTop: 9999 }, 'slow');
return false;
});
});