I have a piece of code below where I am toggling the visibility of a div with the id "popdiv" when a button is clicked. I would like to incorporate a transition effect into this toggle action. Currently, the div simply appears and disappears abruptly without any smooth transition. I have tried adding various transition and animation effects but none seem to be working.
$('#pop').click(function(){
$('#popdiv').toggle();
})
#popdiv{
display: none;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div style="background-color: aqua; width: 50%; height: 20%;" >
<button id="pop">CLICK</button>
</div>
<div style="background-color: cadetblue; width: 30%; height: 40%;" id="popdiv">
POPUP
</div>
Is there a way to achieve the desired transition effect?
Your help is greatly appreciated!