Adding class to elements not working

Adding class to elements not working

I'm using this code:
  1.     <script>
  2. jQuery(window).scroll(function() {   
  3.     var scroll = $(window).scrollTop();
  4.     if (scroll >= 150) {
  5.         $("header").addClass("white");
  6.     } else {
  7.         $("header").removeClass("white");
  8.     }
  9. });
  10. </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?