A quick and dirty approach, using jQuery:
$(document).ready(
function(){
$('#searchbox').keyup(
function(){
var searchText = $(this).val();
if (searchText.length > 0){
$('td:contains(' + searchText +')')
.css('background-color','#f00');
$('td:not(:contains('+searchText+'))')
.css('background-color','#fff');
}
});
});
With the following (x)html:
JS Fiddle demo.
Edited to use addClass()/removeClass(), in place of setting the css in the jQuery itself:
$(document).ready(
function(){
$('#searchbox').keyup(
function(){
var searchText = $(this).val();
if (searchText.length > 0){
$('td:contains(' + searchText +')')
.addClass('searchResult');
$('td:not(:contains('+searchText+'))')
.removeClass('searchResult');
}
else if (searchText.length == 0) {
$('td.searchResult')
.removeClass('searchResult');
}
});
});
Demo at JS Fiddle.
To fade out the table cells that don't contain the search result you can use the following:
jQuery:
$(document).ready(
function(){
$('#searchbox').keyup(
function(){
var searchText = $(this).val();
if (searchText.length > 0) {
$('tbody td:contains('+searchText+')')
.addClass('searchResult');
$('.searchResult')
.not(':contains('+searchText+')')
.removeClass('searchResult');
$('tbody td')
.not(':contains('+searchText+')')
.addClass('faded');
$('.faded:contains('+searchText+')')
.removeClass('faded');
}
else if (searchText.length == 0) {
$('.searchResult').removeClass('searchResult');
$('.faded').removeClass('faded');
}
});
});
css:
td.faded {
opacity: 0.2;
}
Demo at JS Fiddle.