mirror of
https://github.com/Rainyy21/Front-end-Design-Project.git
synced 2026-10-11 00:30:23 -04:00
search_bar been added
This commit is contained in:
+26
-1
@@ -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";
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user