This works in Firefox and Internet Explorer, but does not work in Chrome, I have tested on multiple computers running Chrome.
Is there something I have missed that causes this not to work in Chrome?
<script>
document.addEventListener('DOMContentLoaded', function() {
var dealBar = function() {
var scroll = document.documentElement.scrollTop;
var sidebarDeals = document.querySelector('#sidebar__deals');
var sidebarAdverts = document.querySelector('#sidebar__adverts');
var adBottom = sidebarAdverts.offsetTop + sidebarAdverts.clientHeight;
if (scroll > adBottom) {
sidebarDeals.className = "sidebar__deals--fixed";
} else {
sidebarDeals.className = "sidebar__deals--relative";
}
}
window.addEventListener('scroll', function(e){
dealBar();
});
dealBar();
});
</script>
I get no errors in the Console.