Newsletter

document.addEventListener('DOMContentLoaded', function() { // Select all audio modules with the custom class var audioModules = document.querySelectorAll('.custom-audio-module'); audioModules.forEach(function(module, index) { // Create a container for the counter var counterContainer = document.createElement('div'); counterContainer.classList.add('counter-container'); counterContainer.innerHTML = '0'; // Append the counter container to the module module.appendChild(counterContainer); // Get the audio element var audio = module.querySelector('audio'); // Initialize the counter var counter = 0; // Add play event listener to the audio element audio.addEventListener('play', function() { counter++; document.getElementById('audio-counter-' + index).textContent = counter; }); }); });