adding a background color to search term results
- by turborogue
I'm trying to add a background color to a user submitted search result when a user enters a search term on a page (which is basically one big table). This is a text based search. I'm using jquery to show/hide the table rows that do not have the search term as text within the TR, but I'd ideally like to take the additional step of taking the search term (the entered value), and matching any of those text terms in the remaining (showing) rows and adding say a yellow background to the word(s). I know my syntax is currently wrong, just not sure what is correct:) Hopefully this is clear...any help is greatly appreciated!
html of form:
jquery:
$("#searchsubmit").click(function () {
var searchexp = document.getElementById('searchbox').value;
$("table tr").hide();
$("table tr.header").show();
$('tr:contains('+ searchexp +')').show();
$(searchexp).css('background-color','yellow');
});