I want to create a sticky headline. Each time the user scrolls down and the original heading leaves, then the heading βstickyβ should begin.
I am currently using this:
$(function(){
var stickyHeaderTop = $('#sticky').offset().top;
$(window).scroll(function(){
if( $(window).scrollTop() > stickyHeaderTop ) {
$('#sticky').addClass("sticky");
} else {
$('#sticky').removeClass("sticky");
}
});
});
Although, the current one adds a sticky class whenever the user simply scrolls, not when the original title needs to be removed.
Hi
source
share