Each time a button is clicked, a <div id="fondonegro">
appears which contains menu type information. When you do not click on <div id="fondonegro">
that makes a display:none
with Javascript.
It is a duplicate button, the 1st button has as id="1"
and the second id="2"
. When you click on id="1"
you do the function menu()
, and if you click on id="2"
do menu1 ()
I would like that when you do not click on <div id="fondonegro">
disappear.
function menu() {
document.getElementById("fondonegro").style.display = 'block';
document.getElementById("2").style.display = 'block';
document.getElementById("1").style.display='none';
drop();
}
function menu1(){
document.getElementById("fondonegro").style.display = 'none';
document.getElementById("2").style.display = 'none';
document.getElementById("1").style.display='block';
}
function drop(){
window.onclick = function(event) {
if (!event.target.matches('#fondonegro')) {
menu1();
}
}
}