Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to get row of second tbody in an HTML table

I have three tbody in a table an am able to hide first and second tr in first tbody using following code

$("table.ms-formtable tr:first").hide();
$("table.ms-formtable tr:nth-child(2)").hide();
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.7.1/jquery.min.js"></script>
<table class='ms-formtable'>
  <tbody>
    <tr>
    <td>tbody 1 row 1 cell 1</td>
    </tr>
    <tr>
    <td>tbody 1 row 2 cell 1</td>
    </tr>
  </tbody>
  <tbody>
    <tr>
    <td>tbody 2 row 1 cell 1</td>
    </tr>
    <tr>
    <td>tbody 2 row 1 cell 1</td>
    </tr>
  </tbody>
  <tbody>
    <tr>
    <td>tbody 3 row 1 cell 1</td>
    </tr>
    <tr>
    <td>tbody 3 row 1 cell 1</td>
    </tr>
  </tbody>
</table>

But how do I hide a certain tr in second tbody?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

Maybe you can try to run the following:

$("table.ms-formtable tbody:nth-child(2) tr:nth-child(2)").hide();

The tbody:nth-child(2) specifies the 2nd tbody.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading