How do I set the same code, with different variables, but to perform the same action.
I tried to re-write it and even then, Javascript
is in error, in case it would be a menu in dropdown, with up to 4 levels, I'm still in the 2nd level of it, that when clicking off the menu, the same date
If the user clicks off the menu, it will close
window.onclick = function(event) {
if (!event.target.matches('.dropbtn')) {
var dropdowns = document.getElementsByClassName("dropdown-content");
var i;
for (i=0; i < dropdowns.length; i++) {
var openDropdown = dropdowns[i];
if (openDropdown.classList.contains('show')) {
openDropdown.classList.remove('show');
}
}
}
}
When the user clicks the button, toggles between hide and show content ' Dropdown '
/*Primários*/
function funcaoPrincipais() {
document.getElementById("myDropdown").classList.toggle("show");
}
/*Secundários*/
function funcaoPrincipaisPrincipal() {
document.getElementById("myFirstSubForPrincipal").classList.toggle("show");
}
function funcaoPrincipaisInstitucional() {
document.getElementById("myFirstSubForInstitucional").classList.toggle("show");
}