noobcode noobcode - 1 year ago 69
jQuery Question

Hide only specific <td> from table row based on next class name in CSS or jquery

i am getting table rows based on certain conditions. This is my code structure

<tr start="7" row="1" class="tableinsideth trmain">
<td>&nbsp;</td>
</tr>
<tr start="7" row="1" class="tableinsideth trmain">
<td>&nbsp;</td>
<td class="tdclass dateclass esl" >Available</td>
</tr>


i want to remove only that
<td>
which is just above class
esl
or in other way, remove first td when we have more than 1 td in a row. Tried
~
also in css but didn't get any success. Any help will be highly appreciated.

Answer Source

You can use :first-child to hide first td in tr.

Then use :only-child to make sure that td with no other sibling displays.

tr > td:first-child {
  display: none;
}

tr > td:only-child {
  display: table-cell;
}
<table>
  <tr start="7" row="1" class="tableinsideth trmain">
    <td>&nbspTEST;</td>
  </tr>
  <tr start="7" row="1" class="tableinsideth trmain">
    <td>&nbsp;TEST2</td>
    <td class="tdclass dateclass esl">Available</td>
  </tr>
</table>

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download