Spaces:
Running
Running
File size: 810 Bytes
2f8c35e 568ef55 2f8c35e 568ef55 2f8c35e 710766b 2f8c35e de7f03e 2f8c35e |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
// Wait for the document to load
document.addEventListener('DOMContentLoaded', function () {
// Get all the song containers
const songContainers = document.querySelectorAll('.movie');
// Attach a click event listener to each song container
songContainers.forEach(function (container) {
container.addEventListener('click', function () {
const audio = this.querySelector('audio'); // Get the audio element inside the container
// Toggle the visibility of the audio element
audio.classList.toggle('d-none');
// Check if the audio is playing or paused, and toggle play/pause accordingly
if (audio.paused) {
audio.play(); // Play the audio if it's paused
} else {
audio.pause(); // Pause the audio if it's playing
}
});
});
});
|