+ 1
Javascript Maximum call stack exceeded
Help, I received error: UncaughtError: Maximum call stack exceeded What should I do to fix this error, as you can see, I'm trying to make metronome using JS. The problem is, I received that error. I just would like to chage the speed of animation. https://code.sololearn.com/Wzo0y9Aur468/?ref=app
9 Respostas
+ 2
// Don't forget it :)
// [0] to get the first element
return document.getElementsByClassName('barPercent')[0].style.animationDuration = metronomeBarSpeed;
+ 2
Document.getElementsByClassName()
The getElementsByClassName method of Document interface returns an array-like object of all child elements which have all of the given class name(s).
https://developer.mozilla.org/en-US/docs/Web/API/Document/getElementsByClassName
Have a read
+ 2
Get the first element with a class of 'barPercent', or undefined if there is no matching element:
document.getElementsByClassName('barPercent')[0]
+ 1
not sure if i got this right, but i know this happens in recursive methods
+ 1
// try this .. cssBarSpeed function
document.getElementsByClassName('barPercent')[0].style.animationDuration = metronome.speedOfBeat();
+ 1
SoloProg thanks for trying, there's no error if I put that, but the animationDuration didn't change.
By the way, please enlighten me
What is [0] in [0].style?
What can [0] do?
+ 1
SoloProg thanks I understand now, I just updated the code, please check it again. What I want is, for the animation Speed, or the duration of the animation change. How can I do it?
The error now changed
+ 1
SoloProg thanks so much, you just save me from this problem, it's messing with my brain for a long time XD. Many thanks 🥰
0
Keokix_ yeah I just also learned that just now, thanks for saying that, so how can I solve this problem. I tried putting return statement in every method, but still not working