Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

add class on window scroll

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

     //>=, not <=
    if (scroll >= 500) {
        //clearHeader, not clearheader - caps H
        $(".clearHeader").addClass("darkHeader");
    }
}); //missing );
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #add #class #window #scroll
ADD COMMENT
Topic
Name
9+4 =