Answers for "scroll top and add class"

0

scroll top and add class

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

    if (scroll >= 500) {
        $(".clearHeader").addClass("darkHeader");
    } else {
        $(".clearHeader").removeClass("darkHeader");
    }
});
Posted by: Guest on May-01-2021

Browse Popular Code Answers by Language