Using selectors to find children <th>

Using selectors to find children <th>

My goal is to find those tags with a class of .ht_nestingParent and then add a blank table row above the .ht_nestingParent and then a blank row under the last of it's children rows; which are the rows below that lack the .ht_nestingParent class.

Here is my HTML

  1.             <tbody>
  2. <tr>
  3. <th class="ht_nestingLevels ht_nestingParent"><div class="relative"><span class="rowHeader">1</span>
  4. <div class="ht_nestingButton ht_nestingCollapse"></div>
  5. </div></th>
  6. <td class="">7-ELEVEN</td>
  7. <td class="">22971161</td>
  8. <td class=""></td>
  9. <td class=""></td>
  10. <td class=""></td>
  11. <td class=""></td>
  12. <td class=""></td>
  13. </tr>
  14. <tr>
  15. <th class="ht_nestingLevels ht__highlight"><div class="relative"><span class="ht_nestingLevel_empty"></span><span class="rowHeader">2</span></div></th>
  16. <td class="current highlight"></td>
  17. <td class=""></td>
  18. <td class="">A</td>
  19. <td class="">SOUTH MOD 67 ID FACE||7-11 OKLAHOMA COLORS||95-5/8 X 96-3/4||DWG: SO1067RF.OK (102138)||</td>
  20. <td class="">4</td>
  21. <td class="">2020-02-20</td>
  22. <td class="">2020-01-24</td>
  23. </tr>
  24. <tr>
  25. <th class="ht_nestingLevels ht_nestingParent"><div class="relative"><span class="rowHeader">3</span>
  26. <div class="ht_nestingButton ht_nestingCollapse"></div>
  27. </div></th>
  28. <td class="">7-ELEVEN</td>
  29. <td class="">22983321</td>
  30. <td class=""></td>
  31. <td class=""></td>
  32. <td class=""></td>
  33. <td class=""></td>
  34. <td class=""></td>
  35. </tr>
  36. </tbody>
I'm so new to complex jQuery..or what seems complex to me. Here's a function I was trying to write using the .each method.

  1.         $(document).ready(function() {
  2. $('.htCore tbody tr th.ht_nestingParent').each(function (i) {
  3. $val = $(this).html();
  4. alert($val);
  5. });
  6. });
I don't think my function is right...it's not doing anything. But, isn't there a way to use selectors more thoroughly than I currently am to find the <th> with .ht_nestingParent and the subsequent children below it until it finds the next <th> with .ht_nestingParent?