Animation On Click | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

Animation On Click

I'm trying to create an animation that is triggered when a button is pressed but it doesn't work. What's wrong with my code? https://code.sololearn.com/WgGK1REOmkie/?ref=app

3rd Mar 2020, 8:47 AM
Unrealistic Engineer
Unrealistic Engineer - avatar
13 Answers
+ 4
https://code.sololearn.com/Wiq89K316l3E/?ref=app theres a better way of doing this is by using css transition,
3rd Mar 2020, 9:10 AM
Taste
Taste - avatar
+ 3
here;s more simpler way of doing this. feel free to studying it https://code.sololearn.com/Wy0pTSQ8Y227/?ref=app
3rd Mar 2020, 9:35 AM
Taste
Taste - avatar
+ 1
Thank you! It seems to work but it still says that there's an unexpected end of input on line 11. Is there a way to fix that?
3rd Mar 2020, 9:16 AM
Unrealistic Engineer
Unrealistic Engineer - avatar
+ 1
you have <script> tag in there, remove it
3rd Mar 2020, 9:18 AM
Taste
Taste - avatar
+ 1
I'm actually using your fixed version. It says that there's something wrong on line 11.
3rd Mar 2020, 9:28 AM
Unrealistic Engineer
Unrealistic Engineer - avatar
+ 1
Interesting. The error comes only when I press the button. It works without errors when I click any random spot of the page.
3rd Mar 2020, 9:30 AM
Unrealistic Engineer
Unrealistic Engineer - avatar
+ 1
oooh i see, i didnt really paid attention to the structure. i've edited the code again
3rd Mar 2020, 9:31 AM
Taste
Taste - avatar
+ 1
Shouldn't it work only when the button is pressed?
3rd Mar 2020, 9:31 AM
Unrealistic Engineer
Unrealistic Engineer - avatar
+ 1
Perfect, thank you very much! Now I have to study what I did wrong. 😀
3rd Mar 2020, 9:33 AM
Unrealistic Engineer
Unrealistic Engineer - avatar
+ 1
yes your original code put click listener on the window. thats why i remove it. there's also a mistake in <button onclick
3rd Mar 2020, 9:34 AM
Taste
Taste - avatar
+ 1
Awesome, thank you very much! 😀
3rd Mar 2020, 9:38 AM
Unrealistic Engineer
Unrealistic Engineer - avatar
+ 1
Line 6 'our block element'
3rd Mar 2020, 9:54 AM
Samiun Nafis
Samiun Nafis - avatar
+ 1
Css maybe
3rd Mar 2020, 10:01 AM
Florian Vanik
Florian Vanik - avatar