1
Hello
I have a div on my page that is defined as ( display: None ) and when clicking on the link hides or displays, but I’m not understanding why my function is not working.
Code:
function esconder(el)
{
var esconder = document.getElementById(el).style.display;
if(esconder == "none")
{
alert("Exibir: " + el);
esconder.style.display = "block";
}
else
{
alert("Esconder: " + el);
esconder.style.display = "none";
}
}
Thank you
Thank you very much Sergio, but I did not understand your explanation very well.
– abduzeedo
@abduzeedo what he said is that when you did it
var esconder = document.getElementById(el).style.display;
and tried to spin it afteresconder.style.display = "block";
would be the same as doing this:document.getElementById(el).style.display.style.display = "block";
, that is wrong.– Guilherme Nascimento
@abduzeedo added a more detailed explanation.
– Sergio
Perfect, now I understand, it really didn’t make sense my code, thank you
– abduzeedo