I have the following code to have a div that sticks after it's scrolled. It works in all modern browsers except IE (8, 9 or 10).
Any quick fixes? Much appreciated.
<script>
//turns sidebar into fixed scrolling
var header = document.querySelector('.stickySidebar');
var origOffsetY = header.offsetTop;
function onScroll(e) {
window.scrollY >= origOffsetY ? header.classList.add('sticky') :
header.classList.remove('sticky');
}
document.addEventListener('scroll', onScroll);
</script>