Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function search() {
- let matches = Array.from(document.querySelectorAll("#towns li"));
- matches.map(
- (m) => (m.style = "font-weight: normal; text-decoration: none")
- );
- let resultNum = 0;
- let searchedText = document.getElementById("searchText").value;
- let resultEl = document.getElementById("result");
- resultEl.textContent = 0;
- for (let i = 0; i < matches.length; i++) {
- if (matches[i].textContent.includes(searchedText)) {
- matches[i].style = "font-weight: bold; text-decoration: underline";
- resultNum += 1;
- }
- }
- resultEl.textContent = `${resultNum} matches found`;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement