infidel-cupper-theme/assets/js/search.js

22 lines
573 B
JavaScript
Raw Permalink Normal View History

2022-11-14 11:16:26 -05:00
(function () {
function onEvent() {
var filter = search.value.toUpperCase();
var list = document.getElementById("list");
var listItems = list.getElementsByTagName("li");
for (i = 0; i < listItems.length; i++) {
var item = listItems[i];
var text = item.innerText.toUpperCase();
if (text.indexOf(filter) > -1) {
item.style.display = "";
} else {
item.style.display = "none";
}
}
}
var search = document.getElementById("search");
if (search) {
search.addEventListener("keyup", onEvent);
}
})();