-3
I want to make a modal where I can view the registration and if I click to Edit up the other modal, thus switching between forms.
HTML with modal:
<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#exampleModal">
Launch demo modal
</button>
<div class="modal fade" id="exampleModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLabel">Modal title</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<div class="visualizar">
<form>
Exemplo
<button type="button" class="btn-editar">Editar</button>
</form>
</div>
<div class="form-edita">
<form>Exemplo2
<button type="button" class="btn-canc-edit" >Cancelar Edição</button>
</form>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
<button type="button" class="btn btn-primary">Save changes</button>
</div>
</div>
</div>
</div>
Javascript:
<script>
$('.btn-editar').on("click", function () {
$('.form').slideToggle();
$('.visualizar').slideToggle();
});
$('.btn-canc-edit').on("click", function () {
$('.visualizar').slideToggle();
$('.form').slideToggle();
});
</script>
CSS:
<style type="text/css">
.visualizar {
display: block;
}
.form-edita {
display: none;
}
</style>
When I click to appear the Edit, it appears, but is not on top of the preview.