1
如何在點擊單個元素時切換音頻?點擊元素切換音頻?
請參閱小提琴http://jsfiddle.net/rabelais/zy2jD/1/
$("#one").toggle(function() {
$('#sound-1').get(0).play();
});
如何在點擊單個元素時切換音頻?點擊元素切換音頻?
請參閱小提琴http://jsfiddle.net/rabelais/zy2jD/1/
$("#one").toggle(function() {
$('#sound-1').get(0).play();
});
這是播放/暫停歌曲: http://jsfiddle.net/RGJCf/36/
HTML:
<div id="one" class="bar1">
<i class="play">I tried to tell you</i>
<i class="stop">I tried to tell you</i>
</div>
CSS:
.stop{
display:none;
}
JS:
$("#one").click(function() {
if ($('#sound-1').get(0).paused == false) {
$('#sound-1').get(0).pause();
alert('music paused');
} else {
$('#sound-1').get(0).play();
alert('music playing');
}
$('i').toggle();
});