jQuery - show and hide element upon scroll down and up

0 votes
185 views
added Jun 20, 2019 in jQuery by LC Marshal Captain (25,790 points)
var downScroll = 0;
$(window).scroll(function(event){
    var scroll = $(this).scrollTop();
    if (scroll > downScroll){
    // downscroll
    shareBtn.removeClass('pos-fixed share');
    } else {
    // upscroll
    shareBtn.addClass('pos-fixed share');
    }
    downScroll = scroll;
 });

 

lazacode.org - Malaysia's programming knowledge sharing platform, where everyone can share their finding as reference to others.
...