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"; } } }
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter