У меня есть HTML-страница с шестью кнопками. Каждая кнопка имеет обработчик события onClick, и при нажатии будет воспроизводиться звук. Звуки в формате mp3. Теперь, когда я нажимаю на любую кнопку, звук будет воспроизводиться, но если я нажму на другую кнопку, когда воспроизводится первый звук, то первый звук перестанет воспроизводиться. После этого, если я нажму на любую кнопку, звук не будет воспроизводиться.
Я не могу понять проблему. Спасибо за помощь.
Вот мой код.
<div
style='display: block; background-image: url(./images/backgroundImage.jpg);' >
<button class="stage1" id="button_1" style="width: 280px;height: 130px; margin-top: 40px;margin-left: 40px; background: transparent; "onclick="audio('a')" ></button>
<button class="stage1" id="button_2" style="width: 280px;height: 340px; margin-top: 20px;margin-left:960px;background: transparent; "onclick="audio('ab')"></button>
<button class="stage1" id="button_3" style="width: 220px;height: 250px; margin-top: 390px;margin-left: 40px;background: transparent; "onclick="audio('abc')"></button>
<button class="stage1" id="button_4" style="width: 220px;height: 250px; margin-top: 390px;margin-left: 300px;background: transparent; "onclick="audio('abcd')"></button>
<button class="stage1" id="button_5" style="width: 220px;height: 250px; margin-top: 390px;margin-left:560px;background: transparent; "onclick="audio('abcde')"></button>
<button class="stage1" id="button_6" style="width: 400px;height: 250px; margin-top: 390px;margin-left:840px;background: transparent; "onclick="audio('abcdef')"></button>
</div>
В Javascript:
function audio(audio_name) {
audioElement.setAttribute('src', 'audio/' + audio_name + '.mp3');
audioElement.play();
}
pause
в своем предыдущем комментарии, который вы только что удалили! - person Harsha Venkatram   schedule 03.06.2013