How to get animation to reverse during second click

So what if I apply a fade in animation to a div, when i click something. Then I want it to fade out after I click another button.

What should I do to achieve this? I have already done the fade in, but I cannot do the fade out?

Add a class on the element that specifies that it’s visible. Then apply the fade out animation to that class (or vice versa, or both, you’d need to play around with combinations a bit)

What if I changed the visibility / display:block in Javascript?

I’m not sure how that’s going to affect anything, CSS just allows you to describe the animations, and you have to apply those to an element. CSS can’t tell if an element has already been animated or not, you need to add something to the HTML (using JS) to be able to do that.

thanks mate, i couldnt get it to work, but it’s a hassle and probably a byproduct of my slap job and first attempt at js css work