Alex Rivera | Logout

How to select first row of the first table in an html page using jQuery?

Asked 2009-05-08T08:52:58.680
22

Suppose if I have multiple tables in my HTML page (without their 'id' attribute), so how can I select first row of the first table or any specific table using jQuery selectors?

Edit
Report

1 Answer

34
$("table:first > tr:first")

or

$("table:first").find("tr:first")

or

$("table:first").children("tr:first")

or

$("table").eq(0).children("tr").eq(0)

So if I understand the followup question...

$("table:eq(1) tr:has(table:eq(2))")

translates to: get any tr's in the 2nd table's if the tr has a 3rd table

or

$("table").eq(1).children("tr:has(table:eq(2))")
answered 2009-05-08T08:55:28.097

Your Answer