When you click on one of the buttons on the page a modal with a form should open. But each button must contain a different form. I used the following code:
<script type="text/JavaScript">
// teste para ocultar menu
var ocultar = document.getElementById('header');
//Obter o modal
var modal = document.getElementById('myModal');
//Obter o botão que abre o modal
var btn = document.getElementById('myBtn');
//Obter o elemento <span> que fecha o modal
var span = document.getElementsByClassName("close")[0];
//Quando o usuário clicar no botão, abra o modal
btn.onclick = function() {
modal.style.display = 'block';
ocultar.style.display = ("none");
}
//Quando o usuário clicar em <span> (x), feche o modal
span.onclick = function() {
modal.style.display = 'none';
if(ocultar.style = "none"){
ocultar.style = ("block !important");
}
}
//Quando o usuário clica em qualquer lugar fora do modal, feche-o
window.onclick = function(event) {
if (event.target == modal) {
modal.style.display = "none";
ocultar.style = ("block !important");
}
}
But the modal is only working on the first button. On the other buttons, nothing happens. I already checked the Google Chrome console, and it does not show any error.
If you want to take a look > > > SITE WITH THE BUTTONS