0

I'm developing a web application for smartphone with HTML5 and jQuery mobile, and I have somewhere in my page 5 buttons (5 options), so I would like to play a different beep sound for each button. How can I do this!!

Rayhoun Mido
  • 1
  • 1
  • 2
  • Take a look at this SO question http://stackoverflow.com/questions/1933969/sound-effects-in-javascript-html5 – davids Aug 20 '12 at 07:42

1 Answers1

0

Somewhere in your HTML:

<button id="button1Id">Button 1</button>

Set up listeners to the buttons, for instance:

$("#button1Id").click( function (event) {
    //Prevent the default button action (I suppose the default click sound is,
    //if it exists on thedevice, is removed by this)
    e.preventDefault(event);

    //TODO: Insert code for audio file playback here

    $.mobile.changePage("destination.html");
}

Then you could just repeat this code for all different buttons. I didn't include code for audio playback since it's not clear in the question if you need help with that. There's several ways to achieve it, you could for instance use: https://developer.mozilla.org/en-US/docs/HTML/Element/Audio

Oberheim
  • 78
  • 11