I'd like to hide/show an element with addClass and removeClass function animation with CSS transition. I tried in this way but when I addClass "active" display not shown.
.hidden {
display: none;
-webkit-transition: display .5s ease;
-moz-transition: display .5s ease;
-o-transition: display .5s ease;
}
.active {
transition: display .5s ease;
-webkit-transition: display .5s ease;
-moz-transition: display .5s ease;
-o-transition: display .5s ease;
}
#test {
width: 100px;
height: 40px;
background: red;
}
-
$('#btn').on('click', function(){
$('#test').toggleClass('active');
});
-
<div id="test" class="hidden">Hallo!</div>
<input type="button" id="btn" value="show/hide">
How could I do it? thank you