Skip to content

Instantly share code, notes, and snippets.

@Tsunamijaan
Created January 5, 2019 09:25
Show Gist options
  • Save Tsunamijaan/848cc228e208bb66d3138bbf2a65b3c6 to your computer and use it in GitHub Desktop.
Save Tsunamijaan/848cc228e208bb66d3138bbf2a65b3c6 to your computer and use it in GitHub Desktop.
Sticky header after scroll
$(window).scroll(function() {
if ($(window).scrollTop() > 100) {
$('.main_h').addClass('sticky');
} else {
$('.main_h').removeClass('sticky');
}
});
if you want to add stick menu on custom div scroll=====
$(window).scroll(function() {
if ($("your_div").scrollTop() > 100) {
$('.main_h').addClass('sticky');
} else {
$('.main_h').removeClass('sticky');
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment