2
I’m using a side menu on a site and I wanted it to retract with a click on the button... it turns out it’s only happening after two clicks!!
function resp() {
var clique = document.getElementById("btn-menu");
var menuLateral = document.getElementById("menu-lateral");
clique.onclick = function (e) {
e.preventDefault();
menuLateral.classList.toggle('toggleMenu');
};
}
I’m using a link to call the script function: <a href="#" onClick="resp()" id="btn-menu">
side menu is the id of the side menu div
toggleMenu is the class that is added to div from the side menu
This code I took as someone else’s base, but she didn’t use as Function() and didn’t have an onClick in the tag ... but so mine doesn’t work... does anyone know what it might be?? it’s annoying to have to double-click the retract menu (this only happens at the first touch after updating the page)
Please mark one of the answers with . It doesn’t have to be mine, but it’s very important to mark an answer that helped you or report what didn’t help. Obg!
– Sam