Syed Syed - 9 months ago 99
jQuery Question

Get second td of tr using jquery

I'm trying to get td values of tr.. but unfortunately it's not working.. may be there is something wrong

My html looks like

<tr class="dname">
<td>value here</td>

My jquery code is

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

What's wrong in this ?

Answer Source

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>.

The following should work: