I have a scenario where I would like to select rows from a table depending upon the values in td
e.g. I have a table like this
-
$("tr").each(function (index) {
if ($.trim($(this).find('td:eq(0)').text()) == x &&
$.trim($(this).find('td:eq(1)').text()) == y) {
$(this).closest('table').css('border', '1px solid red'); // this should do it
}
});
Alternatively, using .filter:
$("tr").filter(function() {
return $.trim($(this).find('td:eq(0)').text()) == 'John' &&
$.trim($(this).find('td:eq(1)').text()) == 'Smith';
}).closest('table').find('tr').css('border', '1px solid red');
Demo: http://jsfiddle.net/WhFbE/5/
- 热议问题