Use jquery to create div after user scroll

I want the div to appear after the user scrolls down on the page and disappears if they scroll back.

I thought using the .scroll () function in jquery would be useful, but couldn't figure out how to do this.

Any help would be greatly appreciated. Thank!

+3
source share
1 answer

Something like this should do the trick:

$(window).scroll(function() {
    if ($(this).scrollTop() == 0) {
        $("#mydiv:visible").hide();
    }
    else {
        $("#mydiv:hidden").show();
    }
});
+14
source

Source: https://habr.com/ru/post/1782989/


All Articles