Play an audio file in HTML with Javascript
I need to write code where, when you click on an image, an audio file starts playing. If it is clicked again the music stops.
Play a audio file in HTML with Javascript
I need to write a code where, when you click on an image, a music audio file starts playing and if it is clicked again the music stops.
Audio object in JS not working across website
I have an audio element, which plays along with my alert box that shows up when a certain action happens. all of the pages on my website share the same JS file, and my JS file is in assets/js/core.js
, and my audio file is in assets/audio/error.mp3
. The audio only seems to play in index page, which is in the root directory of my website. all of the other pages are in /company/...
and company/legal/...
and so on. (the ...
represent the files that are in the directories.) I know that the page must first fetch the audio file, and the file path for each page would be different, so the JS would have to point to multiple directories.
Audio object in JS not working across website
I have an audio element, which plays along with my alert box that shows up when a certain action happens. all of the pages on my website share the same JS file, and my JS file is in assets/js/core.js
, and my audio file is in assets/audio/error.mp3
. The audio only seems to play in index page, which is in the root directory of my website. all of the other pages are in /company/...
and company/legal/...
and so on. (the ...
represent the files that are in the directories.) I know that the page must first fetch the audio file, and the file path for each page would be different, so the JS would have to point to multiple directories.