2
By clicking on an image I want to perform a sound.
How can I do this function using the event onclick?
Code:
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();
}
Your question appears to be in English, did you want to post it on Stack Overflow in English? If your intention was to post it here in Stack Overflow, edit and translate your question.
– Chun
@Chun, "apparently" is your kindness. She’s in English, rsrsrsrs
– Wallace Maxters
@Bruno Rhafael Could put your HTML code too?
– PauloHDSousa