1
I have two Divs, whose contents will house some Fields specific to my page. I need to keep such Ivs always hidden, so that when necessary, I hide one and display the other and vice versa. For this, I created 4 functions... I don’t know what I’m doing wrong, I don’t know if it’s the right way to go, but it’s not working (Problem: I can’t hide one div and open the other and vice versa... simply, they disappear from the screen...). Someone knows how to help me?
HTML
<div id="divBuscarCpfCnpj" class="search">
</div>
<div id="div-pessoa-fisica-juridica" class="div-pessoa-fisica-juridica1">
</div>
Javascrip
function exibirPainelConsultarCpfCnpj() {
$(this).toggleClass();
$("#divBuscarCpfCnpj").slideToggle();
}
function ocultarPainelConsultarCpfCnpj() {
$("#divBuscarCpfCnpj").slideToggle();
}
function exibirPainelPessoaFisicaJuridica() {
$(this).toggleClass();
$("#div-pessoa-fisica-juridica").slideToggle();
}
function ocultarPainelPessoaFisicaJuridica() {
$("#div-pessoa-fisica-juridica").slideToggle();
}
Thus, it is not working. The two Divs are staying visible:
let divBuscarCpfCnpj = document.querySelector('.divBuscarCpfCnpj');
let divPessoaFisicaJuridica = document.querySelector('.div-pessoa-fisica-juridica1');
function exibirPainelConsultarCpfCnpj() {
if (divBuscarCpfCnpj.style.display == 'none') {
divBuscarCpfCnpj.style.display = 'block';
}
}
function ocultarPainelConsultarCpfCnpj() {
if (divBuscarCpfCnpj.style.display == 'block') {
divBuscarCpfCnpj.style.display = 'none';
}
}
function exibirPainelPessoaFisicaJuridica() {
if (divPessoaFisicaJuridica.style.display == 'none') {
divPessoaFisicaJuridica.style.display = 'block';
}
}
function ocultarPainelPessoaFisicaJuridica() {
if (divPessoaFisicaJuridica.style.display == 'block') {
divPessoaFisicaJuridica.style.display = 'none';
}
}
more ai you show the div in the case there physical person, when clicking on a button or field is not that?
– Macedo_Montalvão
I call occultPainelPersonFisicaJuritip() and then displayPainelConsultarCpfCnpj() in the page load event...
– Master JR