Forum Discussion
MikeImage
9 months agoCommunity Member
Closing the side menu if open using a JavaScript trigger
Is there a way to verify if the menu is open, close it using JavaScript and if it's closed, do nothing?
At the moment I can only toggle it using this JavaScript.
document.querySelector("#hamburg...
MikeImage
9 months agoCommunity Member
Your right, I don't need to check if it's open. I still had the toggle trigger still in mind so I had to check if it was open to trigger the toggle code.
var modernPlayerMenu = document.querySelector("#hamburger > div");
var isMenuOpen = ! document.body.classList.contains("sidebar-closed");
if (isMenuOpen) {
modernPlayerMenu.click();
}