Професионална програма
Loading...
+ Нов въпрос
bad12 avatar bad12 26 Точки
function search() {
   towns = Array.from(document.querySelectorAll('ul#towns>li'));
   searchText = document.querySelector('input#searchText').value;
   resultDiv = document.querySelector('div#result');

   let matches = 0;
   towns.forEach(townLiElement => {
      let townName = townLiElement.textContent;
      if (searchText && townName.indexOf(searchText) >= 0) {
         townLiElement.innerHTML = `<bold><u>${townName}</u></bold>`;
         matches++;
      }
   });
   resultDiv.textContent = `${matches} matches found`;
}

 

0
Boris.Milanov avatar Boris.Milanov 1 Точки

Благодаря много!

1
27/02/2021 17:14:20