I have two descriptions containing the text SUM, but one that is bold (SUM and one that is not (SUM)). I want to get the td:eq(5) that has a description containing SUM without the b-tag.
The HTML is dynamically generated so I cant put any ID’s, classes and so.
This is my code (it gives me green background on both sum fields):
$('#someTable tr').each(function () {
var tr = $('#someId').closest('tr');
var tdSum = $(tr).find('td:contains("SUM")');
$(tdSum).closest('tr').find('td:eq(5)').css('background-color', 'green');
});
I hope you understand what I am trying to do.
First of all, the
tris already available as the current loop item. To select thetdwhich contains the textSUMbut does not contain thebtag, use selector below as indicated. Then apply the formatting: