I'd suggest (given the requirements and hideous, hideous HTML):
// selects those 'td' elements that are the second child (:nth-child(2))
// of their parent 'tr' element with a 'section-name' attribute that is
// equal to 'Section2', and filters that collection:
$("tr[section-name='Section2'] td:nth-child(2)").filter(function(){
// we retain only those 'td' elements with at least one childNode
// that is a comment-node (nodeType === 8) and contains the string
// supplied to 'indexOf()'
return $(this).contents().filter(function(){
return this.nodeType === 8 && this.nodeValue.indexOf('FieldInternalName="BaselineEUI"') > -1;
// if there is a length (IE there was more than zero matching
// nodes found) we retain the 'td' element we're filtering
}).length;
// moving to the previous 'td' element, and using 'css()' to color its text red:
}).prev('td').css('color', 'red');
References:
- CSS:
- JavaScript:
Node.nodeType
.Node.nodeValue
.String.indexOf()
.
- jQuery: