Yetimwork Beyene
Yetimwork Beyene

Reputation: 2337

What jQuery selector will give me the first element

How can I get the selection of the first td based on the first row using the class name?

<tbody id="logBody">
    <tr class="logArow">
        <td>Log Name</td>
        <td>Log Information</td>
    </tr>
</tbody>

I've gotten this far but got stuck and not sure how to get first child of td....

$("#logBody > tr.logArow").first()

Upvotes: 0

Views: 52

Answers (3)

TGH
TGH

Reputation: 39268

One example that is close to what you already had:

$("#logBody > tr.logArow > td:first")

Upvotes: 0

gdoron
gdoron

Reputation: 150273

Here is a partial list of how it can be done:

$("#logBody > tr.logArow > td:eq(0)")
$("#logBody > tr.logArow > td").eq(0)
$("#logBody > tr.logArow > td:first-child")
$("#logBody > tr.logArow > td").first()
$("#logBody > tr.logArow > td:first")
$("#logBody > tr.logArow > td").slice(0,1)

Upvotes: 2

user788472
user788472

Reputation:

There are multiple ways to do this. Here's one:

$("#logBody td:first-child")

For more, browse this page.

Upvotes: 2

Related Questions