+ 1
Is there a way to add @keyframe animation in a JS function?
4 Answers
+ 1
It can be approximated in CSS through pseudo classes such as ":focus" which you can experiment with.
The cleaner way to use onclick, as you suggested.
https://www.w3schools.com/TAGS/ev_onclick.asp
0
I don't think it is possible in css, there are click and hover scopes but i don't think you are looking for them.
There is however the onclick attribute in html, which refers to a js code. however the script must be written in the html file itself
0
Janning there must be easy way of coding that bridges animation to function.For ex: If I click button x and want to change backcolor of button y Then CSS becomes insufficient.That is the problem.Because you can only change backcolor of what you selected as selector.If I don't select button y , then it is impossible to change color of button y for CSS.There is no bridge to other elements without selecting related component.So, JS must be used but how?
0
Well, if you're convinced about the no CSS thing, that's your prerogative. However, the link provided does include JS for onclick in the Try It, so I would recommend getting a good foundation in HTML vs CSS vs JS so you can tell when one ends and the other begins.