I
I
Ivan Ivanov2018-03-13 19:47:53
css
Ivan Ivanov, 2018-03-13 19:47:53

How to make animation in JS?

Well, I'm trying to make a wheel scroll animation, but for some reason it doesn't work for me....
Here is the code:

var wheel = document.getElementsByClassName("wheel");
wheel.addEventListener('click', function(){
    wheel.style.transitionDuration = '3s';
    wheel.style.transitionTimingFunction = "ease-in-out";
    wheel.style.transform = "rotate(122222deg)";
})

Answer the question

In order to leave comments, you need to log in

1 answer(s)
T
twobomb, 2018-03-13
@twobomb

getElementsByClassName("wheel")
Returns a collection, so either take the first element

var wheel = document.getElementsByClassName("wheel")[0];

Or assign handlers to everyone in the loop

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question