Ao clicar em uma imagem quero executar um som.
Como posso fazer essa função utilizando o evento onclick?
Código:
window.onload = function myCanvas() {
var c = document.getElementById("myCanvas");
var ctx = c.getContext("2d");
var img = document.getElementById("background");
var img2 = document.getElementById("pedal1");
ctx.drawImage(img,5,5);
ctx.drawImage(img2,100,100);
}
function music()
{
var c = document.getElementById("myCanvas");
var ctx = c.getContext("2d");
var audio1 = new Audio();
audio1.src = "audio/samples/F.mp3";
audio1.play();
}