I need help adding transitions to this show/hide js code, the code works for me but I'm struggling with getting these to show/hide smoothly
Any transition will do really, as long as it points me in the direction of getting transitions on both divs that would be perfect
function switchVisible() {
if (document.getElementById('Div1')) {
if (document.getElementById('Div1').style.display == 'none') {
document.getElementById('Div1').style.display = 'block';
document.getElementById('Div2').style.display = 'none';
}
else {
document.getElementById('Div1').style.display = 'none';
document.getElementById('Div2').style.display = 'block';
}
}
}
#Div2 {
display: none;
}
a{cursor: pointer; font-weight: 600;}
<div id="Div1">Div 1</div>
<div id="Div2">Div 2</div>
<a id="Button1" value="Click" onclick="switchVisible();">hide</a>