Thursday, 26 May 2016

How to add and remove class on scroll

  <script>
    $(window).scroll(function() {   
    var scroll = $(window).scrollTop();   
    if (scroll >= 5) {
        $(".navbar").addClass("smallheader");
    }else {
        $(".navbar").removeClass("smallheader");
    }
});
  </script>

No comments:

Post a Comment