单击按钮1时如何播放音频,以及单击按钮2或3时如何暂停/停止?
<a href="#" class="button1">Button 1</a>
<a href="#" class="button2">Button 2</a>
<a href="#" class="button3">Button 3</a>
<audio controls autoplay loop>
<source src="<?php bloginfo('template_directory'); ?>/audio/audio1.ogg" type="audio/ogg">
<source src="<?php bloginfo('template_directory'); ?>/audio/audio1.mp3" type="audio/mpeg">
Your browser does not support the audio tag.
</audio>
最佳答案
$(".button1").click(function() {
$("audio")[0].play();
});
$(".button2").click(function() {
$("audio")[0].pause();
});
关于javascript - 单击按钮后播放HTML音频,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23338783/