JavaScript search

PHOTO EMBED

Thu Jan 14 2021 08:40:27 GMT+0000 (UTC)

Saved by @zinotrust #html

let input = document.getElementById('search');
input.addEventListener("keyup", search);

function search() {
    let inputVal = input.value;
    // input = input.toLowerCase();
    let li = document.getElementsByTagName('li');

    for (i = 0; i < li.length; i++) {
        if (li[i].innerHTML.toLowerCase().includes(inputVal)) {
            li[i].style.display = "";
        } else {
            li[i].style.display = "none";
        }
    }
}
content_copyCOPY