Find first TD with text in a TR with JQuery

html, html-table, jquery

Solution

Here's a simpler, more elegant solution:

$('tr').find('td:not(:empty):first').css('background', 'red');​

Fiddle: http://jsfiddle.net/dandv/JRcEf/

It just says in jQuery what you mean: "target the first `td` in each `tr` that is not empty".

Problem

I am using JQuery to iterate through all TRs in a table, but not all rows have values in the first cell. ``` <TR> <TD>3</TD> <TD>2</TD> <TD>1</TD> </TR> <TD></TD> <TD>3</TD> <TD>2</TD> <TR> </TR> <TR> <TD></TD> <TD></TD> <TD>3</TD> </TR> ``` How can i target the first TD in each row that is not empty and not just the first child? Thanks!

Original source