I have a simple question regarding jQuery selectors. I’m using the tablesorter and I use a selector to filter out a table that has no records.
$('#mytable:has(tbody tr)').tablesorter();
The problem arises when I have multiple sorted tables on the page.
var x = 0;
while(x < 10) {
$('#myTable + x:has(tbody tr)').tablesorter();
x+=1;
}
This doesn’t work because x is not substituted in the selector. I can’t for the life of me see what combination of brackets and quotes will fix this.
Any ideas ?
Use
'#myTable'+x+':has(tbody tr)'as selector.