I just put my navbar html code to a separate reuse-able using jQuery plug-in. The html rendered well which is absolutely no problem.
However, the javascript code I wrote and put in a external/imported script file concerning the navbar dropdown content stopped working now!? @ @
This is the story:
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script>
$(function(){
$('.navbar').load('reuseable.html');
});
</script>
</head>
<body>
<nav class="navbar">
...
</nav>
...at the end of file: before body closing tag, I imported the js:
<script src="js/main.js"></script>
the js contains functions affecting navbar:
$(function() {
$('#dropbtn').mouseenter(function() {
$('.dropdown-content').css('display', 'block');
});
$('#dropbtn').mouseleave(function(){
$('.dropdown-content').css('display', 'none');
})
$('.dropdown-content').mouseover(function() {
$('.dropdown-content').css('display', 'block');
});
$('.dropdown-content').mouseleave(function() {
$('.dropdown-content').css('display', 'none');
});
//side-nav
$('#dropbtn-side').mouseover(function(){
$('#dropdown-content-side').css('display', 'block');
});
$('#dropdown-content-side').mouseleave(function(){
$('#dropdown-content-side').css('display', 'none');
});
});