Sticky Header on Scroll jQuery

Looking for sticky header on scroll jquery? Use this snippet to add sticky class dynamically in your header.

[code]<script>

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

if (scroll >= 100) {
$(“.header”).addClass(“sticky”);
}

else {

$(‘.header’).removeClass(‘sticky’);

}
});

</script>

[/code]

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.