11 lines
480 B
JavaScript
11 lines
480 B
JavaScript
document.addEventListener('input', (e) => {
|
|
const el = e.target.closest('[data-action="filter-table"]');
|
|
if (!el) return;
|
|
const table = document.querySelector(el.getAttribute('data-target') || '');
|
|
if (!table) return;
|
|
const q = (el.value || '').toLowerCase();
|
|
table.querySelectorAll('tbody tr').forEach(tr => {
|
|
const text = (tr.innerText || tr.textContent || '').toLowerCase();
|
|
tr.style.display = text.includes(q) ? '' : 'none';
|
|
});
|
|
}); |