Defining array index in a jQuery selector
I have several tables in my HTML markup which don't have any attributes and I'm wondering: is it possible to define a jQue开发者_如何学JAVAry selector which directly picks eg. the third table?
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")
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.
精彩评论