-
Notifications
You must be signed in to change notification settings - Fork 124
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #169 from PankajR007/pankaj-patch
Added search feature
- Loading branch information
Showing
3 changed files
with
51 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
function filterNames() { | ||
const input = document.getElementById('searchBar'); | ||
const filter = input.value.toLowerCase(); | ||
const ol = document.getElementById('usernamesList'); | ||
const li = ol.getElementsByTagName('li'); | ||
|
||
for (let i = 0; i < li.length; i++) { | ||
const a = li[i].getElementsByTagName('a')[0]; | ||
const textValue = a.textContent || a.innerText; | ||
if (textValue.toLowerCase().indexOf(filter) > -1) { | ||
li[i].style.display = ""; | ||
} else { | ||
li[i].style.display = "none"; | ||
} | ||
} | ||
} |