hacker.tours-website/themes/zen/assets/js/tables.js

30 lines
651 B
JavaScript
Raw Normal View History

2024-06-13 22:14:05 +02:00
/**
* @file
* A JavaScript file for responsive tables.
*/
/* eslint-disable max-nested-callbacks */
(function () {
'use strict';
const tables = document.querySelectorAll('.responsive-table');
tables.forEach(function (table) {
const headers = table.querySelectorAll('th');
const rows = table.querySelectorAll('tbody tr');
rows.forEach(function (row) {
const cells = row.querySelectorAll('td');
cells.forEach(function (cell, i) {
cell.setAttribute('role','cell');
if (headers[i].innerText) {
cell.setAttribute('aria-label', headers[i].innerText);
}
});
});
});
})();