What is the best solution to play an audio file on mouse over via JavaScript? And stop it when the mouse leaves the link. jQuery is available.
<a href="/test.mp3" class="play">play</a>
What is the best solution to play an audio file on mouse over via JavaScript? And stop it when the mouse leaves the link. jQuery is available.
<a href="/test.mp3" class="play">play</a>
http://www.schillmania.com/projects/soundmanager2/
Provides HTML5 + legacy support
<script type="text/javascript">
(function($) {
$(function(){
$("a.play").each(function() {
$(this).mouseover(function(){
var mp3file = $(this).attr('href');
// asign this mp3file to the player and play it
}).mouseout(function() {
// tell the mp3 player to stop
});
});
});
})(jQuery);
</script>
you can use the player that unomi suggested. works great