0
I have two menus, what function to do and how to do, so when open one, close the other? And when clicking outside the close menu also? Thank you!
My code
function menu1() {
document.getElementById('dropdown').classList.toggle('visivel')
}
function menu2() {
document.getElementById('dropdown2').classList.toggle('visivel')
}
.submenu {
display: none;
}
.visivel {
display: flex;
}
<!doctype html>
<html lang="en">
<head>
<title>Title</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<link rel="stylesheet" type="text/css" href="estilo.css">
</head>
<body>
<div>
<button onclick="menu1()">BOTAO</button>
<div class="submenu" id="dropdown">
<div>conteudo1</div>
<div>conteudo2</div>
<div>conteudo3</div>
<div>conteudo4</div>
<div>conteudo5</div>
</div>
<button onclick="menu2()">BOTAO2</button>
<div class="submenu" id="dropdown2">
<div>conteudo1</div>
<div>conteudo2</div>
<div>conteudo3</div>
<div>conteudo4</div>
<div>conteudo5</div>
</div>
</div>
<script type="text/javascript" src="javascript.js"></script>
</body>
</html>
Tried to?
function menu1() {
 document.getElementById('dropdown').classList.toggle('visivel'); document.getElementById('dropdown2').classList.toggle("submenu"); 
 
 }

 function menu2() {
 document.getElementById('dropdown2').classList.toggle('visivel'); document.getElementById("dropdown").classList.toggle("submenu");
 
 }
– Maury Developer