Skip to content

Commit 7e0f45f

Browse files
committed
video16
1 parent 39ddee4 commit 7e0f45f

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

app.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,3 +44,17 @@ hideBox.addEventListener('change',function(e){
4444
list.style.display = "inital";
4545
}
4646
});
47+
48+
// filter books
49+
const searchBar = document.forms['search-books'].querySelector('input');
50+
searchBar.addEventListener('keyup',function(e){
51+
const term = e.target.value.toLowerCase();
52+
const books = list.getElementsByTagName('li');
53+
Array.from(books).forEach(function(book){
54+
const title = book.firstElementChild.textContent;
55+
if(title.toLowerCase().indexOf(term)!= -1){
56+
book.style.display = 'block';
57+
}else{
58+
book.style.display = 'none';
59+
}
60+
})

0 commit comments

Comments
 (0)