Spaces:
Running
Running
File size: 910 Bytes
568ef55 21bf564 568ef55 21bf564 568ef55 a07f405 21bf564 568ef55 710766b a07f405 21bf564 a07f405 710766b 21bf564 de7f03e |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
document.addEventListener('DOMContentLoaded', function () {
const movieContainers = document.querySelectorAll('.movie');
movieContainers.forEach(function (container) {
container.addEventListener('click', function () {
const audio = this.querySelector('audio');
// Pause all other audio elements except the one clicked
movieContainers.forEach(function (otherContainer) {
const otherAudio = otherContainer.querySelector('audio');
if (otherAudio !== audio && !otherAudio.paused) {
otherAudio.pause();
otherAudio.classList.add('d-none'); // Hide other audio elements
}
});
// If audio is paused or not already playing, play it
if (audio.paused) {
audio.play();
} else {
audio.pause();
}
// Toggle the display of the audio element
audio.classList.toggle('d-none');
});
});
});
|