Get second td of tr using jquery

jQuery find() method returns the descendants of the selected element. You are already selecting the <tr> with a class of dname and then trying to find a descendant which is also a <tr>.

https://api.jquery.com/find/

The following should work:

jQuery(".dname").find("td:eq(1)").text();

Edit: text() instead of val() as @freedomn-m pointed out


Replace n with child no.

$(".dname td:nth-child(n)").text();

For e.g. for 2nd child

$(".dname td:nth-child(2)").text();

You're already filtering on the tr by its class name, so there's no need to find by tr again.

jQuery(".dname").find("td:eq(1)").text()

Also, you need to .text() to get the contents of a <td> not .val().

JSBin here.

Hope this helps :)

Tags:

Jquery