We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 3bc795a commit 0f52f47Copy full SHA for 0f52f47
app.js
@@ -42,4 +42,19 @@ hideBox.addEventListener('change', function(e){
42
} else {
43
list.style.display = "initial";
44
}
45
-});
+});
46
+
47
+// filter books
48
+const searchBar = document.forms['search-books'].querySelector('input')
49
+searchBar.addEventListener('keyup', function(e){
50
+ const term = e.target.value.toLowerCase()
51
+ const books = list.getElementsByTagName('li');
52
+ Array.from(books).forEach(function(book){
53
+ const title = book.firstElementChild.textContent;
54
+ if(title.toLowerCase().indexOf(term) != -1){
55
+ book.style.display = 'block';
56
+ } else {
57
+ book.style.display = 'none';
58
+ }
59
+ })
60
+})
0 commit comments