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:
<table>
<thead>
<tr>
<td colspan="2">
<label for="searchbox">Search:</label>
<input type="text" id="searchbox" />
</td>
</tr>
</thead>
<tbody>
<tr>
<td>Something</td>
<td>More text</td>
</tr>
<tr>
<td>Lorem ipsum</td>
<td>blah?</td>
</tr>
</tbody>
</table>
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.