I'm trying to create a slideUp
and slideDown
function to hide and show elements with javascript animation. I'm animating the height property here but it only works one time.
The div is initially hidden. I use slideDown
on it which calculates its natural height and animates it from 0px to that height, then remove the height property. To slideUp
, it animates it back from the natural height to 0px, then removes height property.
The second time around, JS is not able to measure the correct height of the div. It seems like the browser remembers the last height of the div which was 0 and sticks to that.
Here's my code: https://jsfiddle.net/VeeK727/2ufnsx61/
What is happening here?