function myFunction() {
var input, filter, ul, li, a, i, txtValue;
input = document.getElementById("myInput");
filter = input.value.toUpperCase();
ul = document.getElementById("myUL");
ul.style.display = "block";
li = ul.getElementsByTagName("li");
for (i = 0; i < li.length; i++) {
a = li[i].getElementsByTagName("a")[0];
txtValue = a.textContent || a.innerText;
if (txtValue.toUpperCase().indexOf(filter) > -1) {
li[i].style.display = "";
} else {
li[i].style.display = "none";
}
}
}
This is the code I have for Search but it's not working the way I need it to.
Example:
The element I want to search for is "Water Purifier - New York".
I want it to filter it even when I type Water New in search, but it doesn't. Basically, search needs to look for all elements containing given words regardless of order of those words.