Categories
Code Snippets CSS Javascript JQuery

Add a Class to your Header on Scroll

jQuery( document ).ready(function() {
            
    jQuery(window).bind('scroll', function() {
            
            wrap = jQuery('body');
            scrollTop = jQuery(window).scrollTop();
        
            distance = 50;
                                 
            if (scrollTop > distance)	{
                wrap.addClass("fixed");
            } else {
                wrap.removeClass("fixed");
            }		
        
    });

});

 

Leave a Reply