posted 2 weeks ago
Hi,
Trying to create a page with a responsive sidebar. Just to clarify, I want the menu to appear or disappear at the push of a button.
I've messed around with this for a while, and came up with a modal dialog. However, the button I use to open it doesn't seem to work.
Here's the button code:
<button onclick = "menuButton()" > Menu</button>
In theory, this should open the modal dialog containing the menu. Here's the associated JavaScript:
<script>
const
menuButton = document.getElementById('menubtn'),
trueMenu = document.getElementById('true-menu'),
closeButton = document.getElementById('close-true-menu');
menuButton
.addEventListener(
'click',
() => {
trueMenu.showModal();
}
);
closeButton
.addEventListener(
'click',
() => {
trueMenu.close();
}
);
</script>
I've lost a lot of hair over this one, and any useful hints would be very much appreciated.