Adding a background color to the nav on scroll, and it will randomly not work. I would say 50% of the time it works, 50% I get the ReferenceError. This is multiple devices, and multiple browsers, multiple pages.
<script async src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script>
$(document).ready(function() {
$(document).scroll(function () {
var $nav = $(".masthead");
$nav.toggleClass('navBG', $(this).scrollTop() > $nav.height());
});
});
</script>
.masthead{width:100%;height:80px;position:fixed;top:0;left:0;z-index:9999;box-shadow: 0 50px 50px -20px rgba(0, 0, 0, 0.2) inset;}
.masthead.navBG{box-shadow:0 5px 30px 5px rgba(0, 0, 0, 0.4);background-color:#01417E; !important;transition:background-color 100ms linear;}
<div class="masthead">
<nav id="sidenavContainer" class="sidenav">
<!-- SOME LIs -->
<!-- JS for Nav Functionality -->
</nav>
<div id="navTri" onclick="openNav()"><img src="menu.svg" alt="Menu" width="30"></div>
<div id="logoMain"><a href="#"><img src="logo.svg" alt="Logo"></a></div>
</div>
Error seems to show up consistently in the code snippet. Any thoughts?