document.addEventListener("DOMContentLoaded", function () { document.querySelectorAll('.row_grid.wpea_frontend_archive').forEach(function (grid) { let eventTitle = grid.querySelector('.event_title'); if (eventTitle) { let eventTitleText = eventTitle.textContent.trim(); let eventId = eventTitle.closest('.archive-event')?.getAttribute('data-event-id') || Math.random().toString(36).substr(2, 9); // Assign ID to the event title for aria-labelledby eventTitle.setAttribute('id', `event-title-${eventId}`); // Find all links inside the grid grid.querySelectorAll('a[href]').forEach(function (link) { let linkText = link.textContent.trim(); if (link.querySelector('.event_date')) { // If link contains a date, use aria-labelledby link.setAttribute('aria-labelledby', `event-title-${eventId}`); } else { // Otherwise, use aria-label if (!link.hasAttribute('aria-label')) { link.setAttribute('aria-label', eventTitleText); } } }); } }); // 🔹 Replace all tags with for better accessibility document.querySelectorAll('i.fa-map-marker').forEach(function (icon) { let span = document.createElement('span'); span.className = icon.className; // Copy class names span.setAttribute('role', 'img'); span.setAttribute('aria-label', 'Location'); // Replace with icon.replaceWith(span); }); });