Created
February 20, 2024 15:37
-
-
Save dd701116/2cf20c14a32e1c92e45e974750ef4b29 to your computer and use it in GitHub Desktop.
Search in select options
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
const searchInput = document.getElementById("search-in-select-input") | |
const selectTagToManage = document.getElementById("csvBoxAbove") | |
function searchInSelect(value) { | |
for (let index = 0; index < selectTagToManage.options.length; index++) { | |
selectTagToManage.options[index].hidden = !(new RegExp(`${value}`, "ig")).test(selectTagToManage.options[index].value) | |
} | |
} | |
searchInput.addEventListener("keyup", () => searchInSelect(searchInput.value)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment