Adding class to elements not working
I'm using this code:
- <script>
- jQuery(window).scroll(function() {
- var scroll = $(window).scrollTop();
- if (scroll >= 150) {
- $("header").addClass("white");
- } else {
- $("header").removeClass("white");
- }
- });
- </script>
When the user scrolls, the class 'white' is to be added to the <header>
element , and it's not. I don't know if I'm experiencing a conflict somewhere? Can someone take a look?