Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mathiasbynens/243946 to your computer and use it in GitHub Desktop.
Save mathiasbynens/243946 to your computer and use it in GitHub Desktop.
Playing sounds on mouseover using jQuery. Using <embed>, because who needs <audio> anyway‽
var $sound = $('<div id="sound" />').appendTo('body');
$('#special-links-that-play-annoying-sounds-when-hovered a').hover(function() {
$sound.html('<embed src="foo.mp3" hidden="true" autostart="true" loop="false">');
}, function() {
// We could empty the innerHTML of $sound here, but that would only slow things down.
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment