I have a link <a href="#" id="button">click</a>
on my page and I want to play a notification or alert beep on click. How can I do this using jQuery?
Asked
Active
Viewed 4,895 times
1
-
possible duplicate of [Cross-platform, cross-browser way to play sound from Javascript?](http://stackoverflow.com/questions/187098/cross-platform-cross-browser-way-to-play-sound-from-javascript) – kapa Apr 14 '11 at 07:56
-
no.. the question is different... I already made a walk.. – Alfred Apr 14 '11 at 11:27
3 Answers
1
use the jQuery sound plugin.

Caspar Kleijne
- 21,552
- 13
- 72
- 102
-
Just in case someone actually believes this can't be done in plain javascript, here's the code in that plugin: `$("body").append('');` – Christian Apr 14 '11 at 07:39
0
You don't need jQuery..
<BGSOUND ID="SOUND_ID" LOOP=1 VOLUME="-200" SRC="mySound.mid">
document.all['SOUND_ID'].src='mySound.mid';
If you need a more fancy player you will need to embed on of those Flash player and pass your mp3 file as source. Search for it, there are many.

halfer
- 19,824
- 17
- 99
- 186

Robin Maben
- 22,194
- 16
- 64
- 99
-
210 years ago it would have been a great tip :). AFAIK it is supported only in IE, but in IE8 they might have stopped supporting it. – kapa Apr 14 '11 at 07:33
-
I agree. But the jQuery sound plugin in Caspar's answer builds around pretty much the same thing. – Robin Maben Apr 14 '11 at 07:38
0
You can use HTML5's audio
element.
HTML5 audio on Nettuts - there is a jQuery example

kapa
- 77,694
- 21
- 158
- 175