views:

18

answers:

2

hi,

i'm having several tables in my html markup which dont have any attributes and i'm wondering: is it possible to define a jquery selector which directly picks eg. the 3rd table?

thx

+1  A: 

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.

Tim
+1  A: 

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")
Nick Craver