views:

30

answers:

2

I'm looking to select columns 2-4 on the 2nd row in a table. Does jquery have any sort of "and" function in their selectors? Or would I have to do something like this?

$('#id tr:eq(1)').find('td:lt(5)').find('td:gt(1)')
+1  A: 

I haven't tried this but theoretically it should work:

$('#id tr:eq(1) td:lt(5):gt(1)')
Kerry
+1  A: 

.slice() works well

$('#tableId tr').eq(1).find('td').slice(1,4); //2nd row, 2nd-4th td

$('#tableId tr').slice(1,5); // get specific rows

$('#tableId td').slice(1,4) // get specific columns

$('#tableId tr').each(function() {
     // do code per row
     var $columnRange = $(this).find('td').splice(1,4);
});
Dan Heberden