Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
162 views
in Technique[技术] by (71.8m points)

javascript - Add class to nearest tr with jQuery

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>
question from:https://stackoverflow.com/questions/65901586/add-class-to-nearest-tr-with-jquery

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...