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?
2 Respostas
+ 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>
0
you can make it with css using :focus.
this code will work when you click on button
for example
button:focus{
YOUR CODES
}