Untitled
unknown
plain_text
8 days ago
1.2 kB
2
Indexable
function filterStations() { const query = document.getElementById('stationSearch').value.toLowerCase(); document.querySelectorAll('.category-container').forEach(category => { let categoryHasVisibleStation = false; category.querySelectorAll('.radio').forEach(station => { const stationName = station.textContent.toLowerCase(); if (stationName.includes(query)) { station.style.display = 'block'; categoryHasVisibleStation = true; } else { station.style.display = 'none'; } }); // Get the category title (which is a sibling element of the container) const categoryTitle = category.previousElementSibling; if (categoryHasVisibleStation) { category.style.display = 'flex'; if (categoryTitle && categoryTitle.classList.contains('category')) { categoryTitle.style.display = 'block'; } } else { category.style.display = 'none'; if (categoryTitle && categoryTitle.classList.contains('category')) { categoryTitle.style.display = 'none'; } } }); }
Editor is loading...
Leave a Comment