I have a menu with submenu items that fly out on hover and/or click. Everything works the first time you load a page but if you visit another site/page and come back the fly out doesn't execute. (All of the other scripts on the page work fine.) I get these error messages and it looks like it just doesn't think the menu.htm file has loaded.
jquery-3.6.0.min.js:2 jQuery.Deferred exception: Cannot read property 'addEventListener' of null TypeError: Cannot read property 'addEventListener' of null... jquery-3.6.0.min.js:2 Uncaught TypeError: Cannot read property 'addEventListener' of null at menu.js:29..
menu.js is in bundle.js which is way over my head to modify. How would I force menu.htm to reload every time or make menu.js recognize the cache?
<head>
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
</head>
<body>
<header class="page-header inverse">
<div class="page-header__inner">
<div id="menu" class="container"></div>
</div>
</header>
<script>
$("#menu").load("menu.htm");
</script>
<main>Content</main>
<script src="js/vendors.js"></script>
<script src="js/bundle.js"></script>
</body>