Here is a input
that filters a <ul>
based on the value in pure JavaScript. It works by handling the onkeyup
and then getting the <li>
s and comparing their inner element .name
with the filter text.
jsFiddle
var input = document.getElementById('input');
input.onkeyup = function () {
var filter = input.value.toUpperCase();
var lis = document.getElementsByTagName('li');
for (var i = 0; i < lis.length; i++) {
var name = lis[i].getElementsByClassName('name')[0].innerHTML;
if (name.toUpperCase().indexOf(filter) == 0)
lis[i].style.display = 'list-item';
else
lis[i].style.display = 'none';
}
}