Spaces:
Running
Running
// 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 | |
} | |
}); | |
}); | |
}); | |