+ 1
I NEED HELP!!!! Js
Why when i press on button music dont stop playing? https://code.sololearn.com/Wp7OFZ9YeLLu/?ref=app
3 Answers
+ 3
If you move your these two lines into the window.onload function, it should work out.
var mySong = new Audio();
mySong.src ="...";
The way it's running right now, you're redefining mySong every time you click the button, so it can't pause it, and every other time the button is clicked a new instance of the song will start playing (on top of what's already playing). By moving these two lines into the window.onload function, the song is defined once, and the pause function can work properly.
Hope this helps!
Final code here:
https://code.sololearn.com/W13nmxDgVa4r/#html
0
thanksss!! even stackoverflow cant help me!!! you are best!!
0
Happy to help :)