jQuery Add Class On Scroll

You can this jQuery script to make your menu sticky when scroll or to make your “Move to top” button.

$(window).scroll(function () {
    var scroll = $(window).scrollTop();

    if (scroll >= 500) {
        $("#header-menu").addClass("sticky");
    } else {
        $("#header-menu").removeClass("sticky");
    }
});

Leave a Comment

Your email address will not be published. Required fields are marked *