Why an error? How to make it correct? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 3

Why an error? How to make it correct?

Here is my code https://code.sololearn.com/WgDhd20XQf5R/?ref=app Why is it showing an error? How can I correct it? Thanks for answering.

17th Oct 2017, 1:55 PM
Isair Calhawk
Isair Calhawk - avatar
7 Answers
+ 8
A little change in JS: ********************* function Se(){ var Ji = document.getElementById("Re"); Ji.style.animationName="Cri"; } ********************* This will definitely work!:)
17th Oct 2017, 2:15 PM
Biraj Patel
+ 10
Where is the id "Re"? You should specify it somewhere (for any tag), like if you want it on your button, you can do : <button id="Re" onclick="Se()">Bi<button> And, for the CSS, id's are defined using a "#" before it.
17th Oct 2017, 2:00 PM
Dev
Dev - avatar
+ 9
That's because you didn't put Cy in the @-webkit-keyframes part or Cri in the animation-name part. Try implementing either of the two!
17th Oct 2017, 2:06 PM
Dev
Dev - avatar
+ 9
@Forge: Exactly what @Biraj said. The animationName property sets or returns a name for the @keyframes animation. Just animation would not do ^^
17th Oct 2017, 2:17 PM
Dev
Dev - avatar
+ 4
@Dev I am trying to control CSS animation through JS function. When someone clicks the button it changes the animation name of Re from Cy to Cri where Cri is defined hence animation will took place.
17th Oct 2017, 2:07 PM
Isair Calhawk
Isair Calhawk - avatar
+ 3
Oh I was in hurry that's why I didn't notice that. But I have tried what you are saying in an previous code and it still not works. Check the Code Here again.
17th Oct 2017, 2:03 PM
Isair Calhawk
Isair Calhawk - avatar
+ 2
Thanks @Biraj and @Dev
17th Oct 2017, 2:24 PM
Isair Calhawk
Isair Calhawk - avatar