Я создаю звуковую дорожку jQuery/PHP, и я пытаюсь выяснить, как код, если я нажму кнопку ONE, который останавливает звук HTML5, прикрепленный ко всем другим кнопкам , Вот мой код до сих пор:jQuery Soundboard - кнопка ONE отключает все остальные кнопки
Jquery:
$(function() {
$("audio").removeAttr("controls").each(function(i, audioElement) {
var audio = $(this);
var that = this; //closure to keep reference to current audio tag
$("#doc").append(
$('<button>'+audio.attr("title")+'</button>').toggle(
function() {
that.play();
$(this).addClass('playing');
},
function(){
that.pause(); that.currentTime = 0;
$(this).removeClass('playing');
}));
});
});
</script>
PHP:
<?php foreach($files as $file) { ?>
<?php $title = str_replace(".mp3", "", str_replace("clips/", "", $file)); ?>
<audio src="<?php echo $file; ?>" controls autobuffer="true" title="<?php echo $title ?>"></audio>
<?php } ?>