0
JS button for CSS effect
I've created an animation with CSS and now I'd like to create a button that activates and deactivate the animation, but my knowledge of JS is very basic and I don't know how to do it. Anyone can help me?
5 Respuestas
+ 2
As in the example, only with an animation instead of a red background.
https://code.sololearn.com/W70fVBDrs6RN/?ref=app
+ 2
The onclick function can give the tag which you want to animate a CSS class which includes the animation.
+ 1
Yes it is possible too. Just do the same as you did with the button. You can take the ID of the div and do the same thing. I have updated the code so you can see it in action.
0
Thanks Alexander. And would it be possible to create a button to do the same but to a different html element?
I mean, when I click the button, the animation applies to a <div> element (and sorry if I'm asking too much, but I'm really lost with this matter 😰)
0
Thanks!