Adding sounds files by using js? | Sololearn: Learn to code for FREE!


Adding sounds files by using js?

I'm trying to make a guitar by using floating divs as the "strings". I have the right sound files to play when each div is touched. Can anyone tell me a way to add the files. Also is it possible for the audio to overlap each other so that I can press multiple divs at once?

7/6/2020 8:06:23 AM

Priyan Vignesh Ramesh

2 Answers

New Answer


If you want to use those guitar sounds on Sololearn then you have to upload them on hosting service like Dropbox. Here is quick guide to do that Now, to play the audio, you can use Audio() class of Javascript. var sound1 = new Audio(); sound1.src = ""; And then have a function that plays the audio and call it on an onclick event. function playAudio() {; }


Thank you for the help!