2

I have several tables in my HTML markup which don't have any attributes and I'm wondering: is it possible to define a jQuery selector which directly picks eg. the third table?

2 Answers 2

1

In addition to Tim's answer, there's a :eq() version you can use inside a selector as well, for example:

$("#myContainer table:eq(2) tr")
Sign up to request clarification or add additional context in comments.

Comments

1

yeah you can use eq from jquery

$('table').eq(2).css('background-color', 'red'); for example this gets the third table (zero-based counting, jquery starts counting with zero therefor eq(2)) and give it a red background color.

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.