I have a function to hide a div and open the data with a href. It works in another form normally, but it does not work in this form that I need that works, it returns me the following error:
message: "div is not defined"
Follow the function:
window.onload = function() {
// Localiza o elemento
var div = document.getElementById('minha_div');
// Esconde a DIV
div.style.display = 'none';
// O link
var clique = document.getElementById('clique');
// Captura o evento de clique no link
clique.onclick = function() {
alert('clique');
// Verifica se getComputedStyle é suportado
if ('getComputedStyle' in window) {
var display = window.getComputedStyle(div).display;
} else {
// Obtém a opção display para navegadores antigos
var display = div.currentStyle.display;
}
// Verifica se display é none
if (display == 'none') {
// Muda para display block
div.style.display = 'block';
} else {
// Muda para display none
div.style.display = 'none';
}
// Retorna falso para não atualizar a página
return false;
}
}
html:
<span class="fundo_clique">
<a href="#" id="clique">Para configurar as mensagens, clique aqui!</a>
</span>
<br />
<%-- MODAL FINANCEIRO LANÇAMENTO DE CONTAS --%>
<span id="minha_div" style="border: none" runat="server">*conteúdo*</span>
I think the problems are in the references, because in another form that does not need these references it works, and in this I need these:
<link rel="stylesheet" href="css/mobile/pessoas_small_1366.css" />
<script type="text/javascript" src="javascript/jquery.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script><scripttype="text/javascript" src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
<script type="text/javascript" src="http://ajax.aspnetcdn.com/ajax/jquery.ui/1.8.9/jquery-ui.js"></script><scripttype="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery.mask/1.14.0/jquery.mask.min.js"></script><linkrel="stylesheet" type="text/css" href="http://ajax.aspnetcdn.com/ajax/jquery.ui/1.8.9/themes/start/jquery-ui.css" />
<script src="javascript/pessoa.js"></script>
<link rel="stylesheet" type="text/css" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" />
<link rel="stylesheet" type="text/css" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap-theme.min.css" />
But in every way I change, the same thing happens.
What can it be?