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
Community Member
This code is not working for some reason.
var modernPlayerMenu = document.querySelector("#hamburger > div");
var isMenuOpen = document.body.classList.contains("sidebar-open");
if (isMenuOpen) {
// The menu is open, so close it
if (modernPlayerMenu) {
modernPlayerMenu.click();
}
} else {
// The menu is already closed, do nothing
}
Jürgen_Schoene_
9 months agoCommunity Member
try not "closed":
var isMenuOpen = ! document.body.classList.contains("sidebar-closed");
https://360.articulate.com/review/content/d1391023-8e8f-494b-ab82-c014b505f9df/review
- MikeImage9 months agoCommunity Member
You are the king.!! This is exactly what I was trying to build.