Sticky header after scroll

$(window).scroll(function() {
    if ($(window).scrollTop() > 100) {
        $('.main_h').addClass('sticky');
    } else {
        $('.main_h').removeClass('sticky');
    }
});

if you want to add stick menu on custom div scroll

$(window).scroll(function() {
    if ($("your_div").scrollTop() > 100) {
        $('.main_h').addClass('sticky');
    } else {
        $('.main_h').removeClass('sticky');
    }
});

Leave a Reply

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