feat: add search functionality to filter books by title or author
This commit is contained in:
@@ -64,5 +64,14 @@ document.getElementById('boton-agregar').addEventListener('click', () => {
|
|||||||
document.getElementById('calificacion').value = "";
|
document.getElementById('calificacion').value = "";
|
||||||
})
|
})
|
||||||
|
|
||||||
|
document.getElementById('searchBar').addEventListener('input', (e) => {
|
||||||
|
const query = e.target.value.toLowerCase();
|
||||||
|
|
||||||
|
const filtered = books.filter((book) =>
|
||||||
|
book.tittle.toLowerCase().includes(query) || book.author.toLowerCase().includes(query)
|
||||||
|
)
|
||||||
|
|
||||||
|
renderTable(filtered);
|
||||||
|
})
|
||||||
|
|
||||||
renderTable(books);
|
renderTable(books);
|
||||||
Reference in New Issue
Block a user