Advertisement
Liliana797979

table - search engine - js advanced

Oct 1st, 2021
158
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function search() {
  2.  
  3.     const searchText = document.getElementById('searchText').value;
  4.  
  5.     const towns = document.querySelectorAll('ul> li');
  6.     let count = 0;
  7.     Array.from(towns).map(e => {
  8.  
  9.  
  10.         if ((e.textContent).includes(searchText)) {
  11.             e.style.fontWeight = 'bold';
  12.             e.style.textDecoration = 'underline';
  13.             count++;
  14.         } else {
  15.             e.style.fontWeight = '';
  16.             e.style.textDecoration = '';
  17.         }
  18.  
  19.     });
  20.     document.getElementById("result").textContent = `${count} matches found`;
  21.  
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement