So far I can get my code to highlite the specific td, but even better would be to highlite the entire row. Does anyone know how to do this?
var mySearch = 'No';
$('table tbody tr td:contains("' + mySearch + '")').filter
(function(){
if($.trim($(this).text()) == mySearch)
$(this).addClass("prequal-status-n");
});
By changing
$(this).addClass("prequal-status-n")to$(this).closest('tr').addClass("prequal-status-n")you can select the entire row rather than just a cell within the row.Here is a jsfiddle of using
.closest()to select thetrparent tag of a cell: http://jsfiddle.net/jasper/LhbUG/Note:
.closest('tr')can be replaced by.parent()as the direct parent of thetdtag is atrtag. Just keep in mind that using.parent()restricts your$(this)selector to being a direct descendant of thetrtag.Here’s some documentation for ya:
.parent(): http://api.jquery.com/parent.closest(): http://api.jquery.com/closest