search_bar been added

This commit is contained in:
Rainy21
2026-02-26 12:25:59 -05:00
parent 69e2ee8258
commit 4e17c2df8c
6 changed files with 75 additions and 7 deletions
+26 -1
View File
@@ -17,4 +17,29 @@ document.addEventListener("DOMContentLoaded", function() {
modal.close();
});
}
});
});
document.addEventListener('DOMContentLoaded',() => {
const searchBar = document.getElementById('mediaSearch');
if(searchBar){
searchBar.addEventListener('keyup', ()=>{
const input = searchBar.value.toLowerCase();
const cards = document.getElementsByClassName('card');
for (let i = 0; i < cards.length; i++) {
// We search all text inside the card (Title, Author, Genre)
const cardText = cards[i].innerText.toLowerCase();
if (cardText.includes(input)) {
cards[i].style.display = "";
}
else {
cards[i].style.display = "none";
}
}
});
}
});