I have a html table as follows
<table id = "table1">
<tr>
<td class="take">1</td>
<td>2</td>
<td>3</td>
<td class="take">4</td>
<td>5</td>
<td class="take">6</td>
</tr>
<tr>
<td class="take">11</td>
<td>12</td>
<td>13</td>
<td class="take">14</td>
<td>15</td>
<td class="take">16</td>
</tr>
</table>
I would like to get a jquery selector which gets me the second td
having class of take
in the first tr
of table. :) funny huh? But it pains.
I tried below.
$("#table1").find('tr:first-child td.take:nth-child(2)').text()
But no use.
EDIT: I want td
having text 4 not 2
I made a fiddle to play around.
you can use direclly,using eq() selector
DEMO
Or,
Try this : You can iterate all
td
s withclass="take"
in first row of table and then check it's index eqaul to 1 (as index is 0 based, second element will have index =1).JSFiddle Demo
You can use
:first
to target first rowtr
along with `:eq' selector with index 1 to target 2nd td element in it:Working Demo
Try this
FIDDLE