jquery - Triggering audio on hover and triggering different audio on click of same div? -


i have div image in it. on hover of image want 1 audio play, on click of same image want audio play. code far, doesn't seem work? ideas? thanks

 <div id="one"> <img src="lib/images/check-mark-32.png" alt=""/></div>  <audio id="sound-1a"> <source src="lib/sound/01 partitano.1.mp3"></source> <source src="lib/sound/01 partitano.1.ogg"></source> browser isn't invited super fun audio time. </audio> <audio id="sound-1"> <source src="lib/sound/01 solo piano - 1 - metamorphosis.mp3"></source> <source src="lib/sound/01_solo_piano_1_metamorphosis.ogg"></source> browser isn't invited super fun audio time. </audio>  <script> var audio = $("#sound-1a")[0]; $("#one").mouseenter(function() { audio.play(); }); var audio = $("#sound-1")[0]; $("#one").click(function() { audio.play(); });  </script> 

try

$("#one").mouseenter(function () {     $('#sound-1a').get(0).play(); }); $("#one").click(function () {     $('#sound-1').get(0).play(); }); 

Comments

Popular posts from this blog

java - Run a .jar on Heroku -

java - Jtable duplicate Rows -

validation - How to pass paramaters like unix into windows batch file -