Get second child using jQuery

Upvote picture Upvote · Jan 18, 2011 · Viewed 280.6k times · Source
$(t).html()

returns

<td>test1</td><td>test2</td>

I want to retrieve the second td from the $(t) object. I searched for a solution but nothing worked for me. Any idea how to get the second element?

Answer

davin picture davin · Jan 18, 2011

grab the second child:

$(t).children().eq(1);

or, grab the second child <td>:

$(t).children('td').eq(1);