本文介绍了在鼠标悬停的音频的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
它是部分工作的,但是我如何获得下面的内容来处理多个音频文件:
It it working partially, but how do I get the below to work with multiple audio files:
<!DOCTYPE HTML>
<html>
<body>
<script language="javascript" src="http://code.jquery.com/jquery-1.4.2.min.js"></script>
<script type="text/javascript">
$(function(){
var birdhover = $('.birds');
var birdaudio = birdhover.find('audio')[0];
birdhover.hover(function(){
birdaudio.play();
}, function(){
birdaudio.stop();
});
});
</script>
<div class="birds" style="width:30px;height:30px;background-image:url(image1.gif');cursor:pointer;">
<audio src="sound1.ogg" preload="auto"></audio>
</div>
<div class="birds" style="width:30px;height:30px;background-image:url('/home/imran/Desktop/images/vowel_short_2.gif');cursor:pointer;">
(image2.gif');cursor:pointer;">
<audio src="sound2.ogg" preload="auto"></audio>
</div>
</body>
</html>
$ b $如果您不介意使用 HTML5,那么您可以使用
HTML5
Both images play the same sound.
推荐答案
:
HTML
HTML
<div class="birds">
<audio src="/sounds/bird.mp3" preload="auto"></audio>
</div>
Javascript
$(function(){
var birdhover = $('.birds');
var birdaudio = birdhover.find('audio')[0];
birdhover.hover(function(){
birdaudio.play();
}, function(){
birdaudio.stop();
});
});
这篇关于在鼠标悬停的音频的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!