Skip to content
Sign UpLog In
This post is read-only. Explore Repls and connect with other creators on Community.View Community
The info in this post might be out of date, check out our docs instead. View docs
1

Js not working

sn236
sn236

Hi, so I was working on an animation and I wanted when the user clicks then the animation should play. So I used animation play state which pauses or runs the animation. But when I added the js it gave me an error -
TypeError: Cannot read properties of undefined (reading'animationPlayState') at move (/script.js:3:15) at HTMLDivElement.onclick (/:12:54)
Is there a way to fix this using js or css.

1 year ago

Voters

Comments

TopNew
1
SixBeeps
SixBeeps

document.querySelectorAll returns a list of elements, not just one. So, x.style doesn't exist (lists don't have styles) and therefore trying to read x.style.animationPlayState will throw an error.

1 year ago
1
sn236
sn236

@SixBeeps
Thanks

1 year ago