aponzani aponzani - 3 months ago 20
jQuery Question

Need JQuery to select a table only if its 1st row has more than 1 column

I need to select and act on a table element with JQuery, but only when it contains at least one row with more than one column. The following selector works, but only gets me part way:

$('#my_table_is:has(tbody tr)').doSomething();

Variations I have tried with no success are:

$('#my_table_id:has(tbody > tr > td:eq(1))').doSomething();
$('#my_table_id:has(tbody tr:nth-child(1))').doSomething();

What combination of selector and filter will make this work?

BTW, the reason I need this is that tablesorter with a multi-column sortList, will apparently blow up when there is only 1 column in the table output.


how about just a good ole check?

if (1 < $('#tbl thead th').size()) ...