01-24-2012 03:51 PM
Hello Experts,
I am trying to play a click sound when the button is clicked in my application , I am unable to get the solution.
Currently I am using the following code :
var audio = document.createElement('audio');
audio.src='button-29.wav';
audio.controls = true;
document.body.appendChild(audio);
Please help me to play the sound when the button is clicked.
Regards,
Sandesh.
Solved! Go to Solution.
01-24-2012 06:50 PM
button.addEventListener("click", function() {audio.play();}, 0);should do it? Of course, you'll have to have created the button before this code. If that doesn't work: - Make sure the "audio" object you created is in scope at the point you execute the above code (or give it an id and get it) - Make sure the wav file is not some format unsupported on the device - Make sure you have the full and correct path to the sound file
01-26-2012 06:17 PM - edited 01-26-2012 08:09 PM
Thanks it worked ![]()