How to start a CSS animation?

Hi,

Jusxt finished the CSS course about transitions and animations (7- Summary | Code with Mosh ). I’m wondering, how can we start an animation “on hover” by example?

And if I want to trigger it through a javascript? Is it enough to add the css class with javascript and then remove it after a while? how to know when to remove it?

I was thinking of animation linked to the status, by example animating a checkbox or radiobutton. Or animated a store cart icon when the user add something in it?