Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function search() {
- const listTown= document.getElementById('towns');
- const resultElement=document.getElementById('result');
- const searchtext= document.querySelector('#searchText').value;
- let matchcount=0;
- const townElements=Array.from(listTown.children);
- for (const town of townElements) {
- if (town.innerHTML.includes(searchtext)) {
- town.style.textDecoration='underline';
- town.style.fontWeight='bold';
- matchcount++;
- }
- }
- const res=`${matchcount} matches found`;
- resultElement.textContent=res;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement