SHARE
TWEET

Untitled

a guest Nov 17th, 2019 70 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. window.onscroll = function() {myFunction()};
  2.  
  3. var navbar = document.getElementById("navbar");
  4. var sticky = navbar.offsetTop;
  5.  
  6. function myFunction() {
  7.   if (window.pageYOffset >= sticky) {
  8.     navbar.classList.add("sticky")
  9.   } else {
  10.     navbar.classList.remove("sticky");
  11.   }
  12. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top