21 lines
812 B
JavaScript
21 lines
812 B
JavaScript
document.addEventListener('DOMContentLoaded', function () {
|
|
const searchInput = document.getElementById('bookSearchInput');
|
|
const bookCards = document.querySelectorAll('.book-card-wrapper');
|
|
|
|
if (searchInput) {
|
|
searchInput.addEventListener('keyup', function(event) {
|
|
const searchTerm = event.target.value.toLowerCase();
|
|
|
|
bookCards.forEach(function(card) {
|
|
const title = card.getAttribute('data-title').toLowerCase();
|
|
const author = card.getAttribute('data-author').toLowerCase();
|
|
|
|
if (title.includes(searchTerm) || author.includes(searchTerm)) {
|
|
card.style.display = '';
|
|
} else {
|
|
card.style.display = 'none';
|
|
}
|
|
});
|
|
});
|
|
}
|
|
}); |