I'm looking for feedback on this live-filter I wrote in JavaScript. You can test it using the included snippet.
(function() {
var searchField = document.getElementById('filter');
var handler = function() {
var text = searchField.value,
nodes = document.getElementsByClassName('phase'),
regexp = new RegExp(text, 'i');
for (var i = 0; i < nodes.length; i++) {
var node = nodes[i];
node.text.search(regexp) < 0 ?
node.parentNode.style.display = 'none' :
node.parentNode.style.display = 'block';
}
};
searchField.onkeyup = handler;
searchField.onchange = handler;
})();
<input type="text" id="filter" />
<ul id="list">
<li><a class="phase">Ruby on Rails</a></li>
<li><a class="phase">The Rails Way</a></li>
<li><a class="phase">Pickaxe Guide</a></li>
<li><a class="phase">jQuery HTML</a></li>
<li><a class="phase">CSS HTML AJAX</a></li>
<li><a class="phase">HTML5 Net Set</a></li>
<li><a class="phase">Node Easy</a></li>
<li><a class="phase">Listing Bloop</a></li>
</ul>