How Search filter javascript with get data from local Storage and parse DOM

426 Views Asked by At

Please How to get data from local storage and parse DOM with the source code below :

const forms = document.forms;
const searchBar = forms['searchBook'].querySelector('input');
searchBar.addEventListener('keyup', (e) => {
  const term = e.target.value.toLowerCase();
  const txt = JSON.parse(localStorage.getItem("TODO_APPS"));
  const books = document.querySelectorAll(".book_item");
  Array.from(books).forEach((book) => {
    const titlee = book.firstElementChild.textContent;
    if (titlee.toLowerCase().indexOf(e.target.value) != -1) {
      book.style.display = 'block';
    } else {
      book.style.display = 'none';
    }
  });
});
0

There are 0 best solutions below