1
I have a web page with a navbar at the top and an iframe that loads another page below.
The idea is that when the user clicks on the menu item via jQuery I fill the src attribute of iframe with the page and it loads. But it’s not working.
The code of the button:
(....)
<li class="nav-item dropdown active mx-3">
<a class="nav-link dropdown-toggle" href="#" id="menuCadastros" role=button data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Cadastros
<span class="sr-only">(Página Atual)</span>
</a>
<div class="dropdown-menu" aria-labelledby="menuCadastros">
<a class="dropdown-item" href="cadastrarmorador.php">Morador</a>
<div class="dropdown-divider"></div>
<a class="dropdown-item" href="" id="cadUser">Usuário</a>
</div>
</li>
(....)
The jQuery is this:
<script type="text/javascript">
$(document).ready(function(){
$('#areaCentral').hide();
$('#cadUser').click(function(){
$('iframe').attr('src','cadastrarusuarios.php');
alert($('iframe').attr('src'));
$('#areaCentral').show();
});
});
</script>