Created
September 3, 2020 10:11
-
-
Save wpflames/8393f0e5ae48a66a060fe6eda7d98224 to your computer and use it in GitHub Desktop.
Add "sticky" class to header when scrolling window - JS
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| window.addEventListener("scroll", function(){ | |
| var header = document.querySelector("header"); | |
| header.classList.toggle("sticky", window.scrollY > 0); | |
| }) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment