Link to home
Start Free TrialLog in
Avatar of g6shasha
g6shasha

asked on

Div tag within a table. How?

How can I hide a section of a table on the fly? I try the follow and it doesn't work.
If I embed another table within it works, but cell no long align. Thanks.

<table>
<div id="1" style="display:none">
<tr>
<td>what to hide this</td>
<td>what to hide this</td>
</tr>
</div>

<tr>
<td>show</td>
<td>show</td>
</tr>
</table>
ASKER CERTIFIED SOLUTION
Avatar of jachin
jachin

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Show/hide divs really only work well when the div marks one cell's contents....so your inner table idea is the solution.  Just set the widths on your table cells to get them to line up.

<table cellpadding="0" cellspacing="0">
<tr>
<td colspan="2">
  <div id="1" style="display:none">
  <table width="500" cellpadding="0" cellspacing="0">
  <tr>
  <td width="100">want to hide this</td>
  <td>want to hide this</td>
  </tr>
  </table>
  </div>
</td>
</tr>

<tr>
<td width="100">show</td>
<td>show</td>
</tr>
</table>
you could just have 2 tables with <div> tags around them.
Avatar of Adam_J
Adam_J

I wrote the code below because I had a table and wanted to be able to expand each row to show / hide more content.  I had exactly the same problem.  Putting <div> tags around <tr> tags within a table is exactly what you want to do, but they must go within a <td> tag.

<table cellpadding="0" cellspacing="0" border="0" summary="main table">
  <tr>
    <td>content where your main row is</td>
  </tr>
  <tr>
    <td>
      <div id="abc">
         <table cellpadding="0" cellspacing="0" border="0" summary="table with your div">
           <tr>
             <td>more content which could be hidden</td>
           </tr>
         </table>
       </div>
     </td>
  </tr>
</table>
This question has been classified abandoned. I will make a recommendation to the
moderators on its resolution in a week or two. I appreciate any comments
that would help me to make a recommendation.

<note>
Unless it is clear to me that the question has been answered I will recommend delete.  It is possible that a Grade less than A will be given if no expert makes a case for an A grade. It is assumed that any participant not responding to this request is no longer interested in its final disposition.
</note>

If the user does not know how to close the question, the options are here:
https://www.experts-exchange.com/help/closing.jsp


Cd&

It is time to clean this abandoned question up.

I am putting it on a clean up list for CS.

<recommendation>
points to jachin

</recommendation>

If anyone participating in the Q disagrees with the recommendation,
please leave a comment for the mods.

Cd&