Auto-hiding navbar that works in IE <p>I made an auto-hiding navbar and it works great in chrome, but IE11 freaks out. the idea is that when you scroll down it hides, but it reappears if you scroll up. In IE11, I scrolled down and it hid the navbar. And then when I scrolled back up nothing happened for a second... and then the navbar appeared and disappeared 3 times in rapid succession... then a few seconds later it did it again. Any idea what's wrong?</p> <pre><code>&lt;script&gt; var lastScrollTop = 0; $(window).scroll(function(){ var st = $(this).scrollTop(); if (st &gt; lastScrollTop){ $('#header').animate({ marginTop: '-70px', opacity: 0 }, 200); } else { $('#header').animate({ marginTop: '0px', opacity: 1 }, 200); } lastScrollTop = st; }); &lt;/script&gt; </code></pre>