1

我有一个带有图像的 div。悬停在此图像上时,我希望播放一个音频,然后单击同一图像时,我希望播放另一个音频。到目前为止,这是我的代码,它似乎不起作用?有任何想法吗?谢谢

 <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>
Your browser isn't invited for 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>
Your browser isn't invited for 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>
4

1 回答 1

1

尝试这个

$("#one").mouseenter(function () {
    $('#sound-1a').get(0).play();
});
$("#one").click(function () {
    $('#sound-1').get(0).play();
});
于 2013-08-23T15:52:35.863 回答