Works for the first time only | Sololearn: Learn to code for FREE!
Новый курс! Каждый программист должен знать генеративный ИИ!
Попробуйте бесплатный урок
0

Works for the first time only

I want to make a timer. By making a css animation that decreases the width of the blue bar till it reaches 0%. At first it asks for the animation duration and everything goes well but when I try to choose the animation duration for the second time it doesn't animate the bar width decreasing so it only works with me for the first time. https://code.sololearn.com/We2jo4xZjVYv/?ref=app

23rd Apr 2021, 6:28 PM
Radwa Hamdy
3 ответов
+ 2
There's probably a better way to do this but what first came to mind for me was to reset the animation value to an empty string. Try inserting this line after you get the div element (var el) using querySelector but above the setTimeout. el.style.animation = ""
23rd Apr 2021, 6:40 PM
CamelBeatsSnake
CamelBeatsSnake - avatar
+ 1
It worked thanks
23rd Apr 2021, 6:43 PM
Radwa Hamdy
0
Radwa Hamdy Glad to hear that. You're welcome.
23rd Apr 2021, 6:49 PM
CamelBeatsSnake
CamelBeatsSnake - avatar