1
It may sound cliché, but I haven’t found or been able to adapt any code here on the site to my needs. I apologize if it’s content redundancy, but in the future it might help other people.
How can I be adding a Fadein and Fadeout effect when opening and closing the element, based on the following javascript script:
So it’s working, but without the simple effect of opening.
OBS: I would also like to know if it is possible that when you click the same button, close the DIV with a Fadeout.
HTML:
<button type="button onclick="Mudarestado('formulario')">Abrir div</button>
Javascript:
function Mudarestado(el) {
var display = document.getElementById(el).style.display;
if(display == "none")
document.getElementById(el).style.display = 'block';
else
document.getElementById(el).style.display = 'none';
}
Is there more than one div you want to open? Each with its own button? Can you put the HTML of that div as well? are elements close to or at different DOM sites?
– Sergio
It’s a single DIV, I just want to open it and close it by clicking the button. It all takes place in the same document, the button on top and then the div. NOTE: div has display:None in CSS.
– Cobra
Yes. I don’t know if you noticed at the beginning of the question, but it’s been a while since I’ve been trying to adapt the solutions I found and couldn’t. I’d be grateful if you could find a solution now.
– Cobra