0

How to add sound effects to buttons?

I'm trying to add sound effects to buttons, with web languages I know for images you need to change the file to direct link, and is there something similar then comes to sounds? can anyone help?

21st Mar 2020, 4:20 PM
Danial Azadpour
Danial Azadpour - avatar
2 Answers
+ 1
For example in html body: <audio id="myAudio" autoplay> <source src="yourAudio.ogg" type="audio/ogg"> <source src="yourAudio.mp3" type="audio/mpeg"> </audio> <button onclick="myFunction()">myButton</button> and script as follows: <script> function myFunction() { var ma = document.getElementById("myAudio").autoplay; document.getElementById("demo").innerHTML = ma; } </script>
21st Mar 2020, 5:30 PM
JaScript
JaScript - avatar
0
you can make it with css using :focus. this code will work when you click on button for example button:focus{ YOUR CODES }
21st Mar 2020, 5:06 PM
meow
meow - avatar