I've been looking for an answer for quite a long time now, But I couldn't find it. All of the answered questions on here did not work for me. I'm making an admin panel which has a sidebar. I want to make a button where if u click on it, the sidebar collapses. This is my code:
HTML
<li class="nav-item mr-3 sidebar-toggle">
<button class="sidebar-toggler btn btn-sidebar-toggle" type="button" id="sidebar-toggler">
<i class="fal fa-bars"></i>
</button>
</li>
I inserted my jQuery file by doing this:
<script type="text/javascript" src="js/jquery-3.3.1.min.js" ></script>
At the bottom of my page. The path to the file is perfectly fine.
jQuery code
$(document).ready(function () {
$('#sidebar-toggler').on('click', function() {
$('#sidebar').toggleClass('active');
$('#navbar-brand').toggleClass('active');
});
});
The weird thing is. If I open up the console with F12 and paste the jQuery code in there, It works perfectly fine. What am I doing wrong?
PS: The classes active do exist. I've tested it in the console (See message above)