i have this code
<tr id="3" class="gradeA odd focus row_selected">
<td class="center">Kids Footwear 2</td>
<td class="sorting_1 center focus">200</td>
<td class="center">50</td>
<td class="center">200</td>
<td class="center">30-34</td>
<td class="center">234-343</td>
<td class="center">200</td>
<td class="center">25</td>
<td class="center">1.23</td>
</tr>
i want to fetch the index value of <td> element which contains the class focus
so if within the <td> element the focus class is set on
first `<td>` then return 0
second `<td>` then return 1
third `<td>` then return 2
and so on.how do i go with this in jQuery?
thank you.
You can use the
indexmethod. If you have more than onetrelement containing atdwith thefocusclass then you will probably want to make the selector specific to thetryou care about:From the jQuery docs:
Update (see comments)
You can use
childrenorfindto get thetdelements from thetr, and then use the above code: