Skip to content
Advertisement

Elementbyclass is not animating my element

NO JQUERY Please

My animation is not working properly I tried to use document.getElementsByClassName but it won’t work at all there’s no error is just that the element is not animating properly.

I want to do a quick change of color and also a small lettering animation but it will not implement on click, nothing will happen. Please help also if there’s any good book about how this works I would appreciate that too.

HTML:

JavaScript

CSS:

JavaScript

Advertisement

Answer

When you use document.getElementsByClassName, you are referencing an array of elements with that class. You need to specify which one you want by referring to the element’s index. Instead, use document.getElementsByClassName("contentMario")[0].style.animationPlaystate="running";.

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement