I am facing an issue with coding a Sidebar that features an animated Burger Menu Button named "navicon1". The Menu Button utilizes the "open" class to create a cool animation effect. Moreover, I aim to have the functions "openNav" and "closeNav" toggled when clicking on the menu button.
Here is what I am looking for:
- Upon the first click on the Menu Button (navicon1), it should change to an X shape (which currently works) and trigger the javascript function "openNav"
- Subsequently, upon clicking the Menu Button again (navicon1), it should revert to its original form (which also works) and execute the javascript function "closeNav"
Below is my code snippet:
$(document).ready(function() {
$('#navicon1,#navicon2,#navicon3,#navicon4').click(function() {
$(this).toggleClass('open');
});
});
function openNav() {
document.getElementById("mySidenav").style.width = "75%";
document.getElementById("main").style.marginLeft = "75%";
document.body.style.backgroundColor = "rgba(0,0,0,0.4)";
}
function closeNav() {
document.getElementById("mySidenav").style.width = "0";
document.getElementById("main").style.marginLeft = "0";
document.body.style.backgroundColor = "white";
check = 0;
}
The other navicons mentioned are solely for styling purposes...
Appreciate your assistance :)