3

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)')

2 Answers 2

3

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

$('#id tr:eq(1) td:lt(5):gt(1)')
Sign up to request clarification or add additional context in comments.

Comments

3

.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);
});

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.