I am trying to add class to nearest tr using jquery but its not working, Below is my html code
$(function() { $('span.disabled-status').closest('tr').addClass('sales-row'); });
.sales-row { color: #C00; }
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <table> <tr> <td width="8%" class=""> <div class="text-left">615</div> </td> <td width="8%" class=""> <div class="text-left">Nichole</div> </td> <td width="8%" class=""> <div class="text-left">Fredericka Carrillo</div> </td> <td width="8%" class=""> <div class="text-left">Lyle Lloyd</div> </td> <td width="8%" class=""> <div class="text-left">[email protected]</div> </td> <td width="8%" class=""> <div class="text-left">870</div> </td> <td width="8%" class=""> <div class="text-left">392</div> </td> <td width="8%" class=""> <div class="text-left">??? ????????</div> </td> <td width="8%" class="sorted"> <div class="text-left"><span class="disabled-status">Value here </span></div> </td> <td align="left" width="20%"> some content here </td> </tr> </table>
2.1m questions
2.1m answers
60 comments
57.0k users