Javascript: style.cssText and classList.add/remove not working *sometimes*
Go to solution
Solved by duncannah,
I noticed you're creating this event listener every time the "onPlay" event is fired, so you're attaching a new event listener every time this is fired, and thus you'll end up having duplicate event handlers cancelling each other out.
You could find another event to listen to, to be able to attach the click handler, or you can define your handler once, so subsequent calls to addEventListener won't attach a new listener the same handler is already attached:
const clickHandler = async function () { /* your handler here */ }; const options = { events: { onPlay: function () { document.getElementById("theatermode").addEventListener("click", clickHandler); } } }
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now