What are the differet ways to select first <tr> from <table> using jquery? [Resolved]

Posted by Prajakta_2701 under jQuery on 9/16/2013 | Points: 10 | Views : 1454 | Status : [Member] | Replies : 3
What are the differet ways to select first <tr> from <table> using jquery?




Responses

Posted by: Allemahesh on: 9/16/2013 [Member] [MVP] Silver | Points: 50

Up
0
Down

Resolved
You can use the below examples:-

1.
$("table:first > tr:first")

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

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

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


Happy Coding.

If it helps you or directs U towards the solution, MARK IT AS ANSWER

Prajakta_2701, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Allemahesh on: 9/16/2013 [Member] [MVP] Silver | Points: 50

Up
0
Down

Resolved
You need to use nth-child() or first-child():

$('.t13Standard tr:first-child')

or

$('.t13Standard tr:nth-child(1)')

The pseudo selectors :first, :eq(), :gt() etc are performed on the result set not in relation to other elements.

The selectors :first-child, :last-child, :nth-child() are performed in relation to the elements.

Happy Coding.

If it helps you or directs U towards the solution, MARK IT AS ANSWER

Prajakta_2701, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Bandi on: 9/18/2013 [Member] [MVP] Platinum | Points: 25

Up
0
Down
Refer this link for first row selector in jquery
http://api.jquery.com/first-selector/

Selecting first row from multiple tables 


You need to use nth-child() or first-child():

$('.t13Standard tr:first-child')or

$('.t13Standard tr:nth-child(1)')The pseudo selectors :first, :eq(), :gt() etc are performed on the result set not in relation to other elements.

The selectors :first-child, :last-child, :nth-child() are performed in relation to the elements


Mark This Response as Answer
--
Chandu
http://www.dotnetfunda.com/images/dnfmvp.gif

Prajakta_2701, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response