Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

<div> nested in <table> doesn't work 1

Status
Not open for further replies.

gareth7

Programmer
Oct 11, 2002
35
GB
I'm using javascript and css to write a function that displays hidden html. The function works for most situations, but in the following code, the div tag doesn't pass on the style i.e. the code inside it remains visible.

<table>
<tr>
<td>text always visible</td>
</tr>

<div style=&quot;display:none;&quot; id=&quot;abc&quot;>
<tr>
<td>hidden text</td>
</tr>
</div>

</table>
 
gareth7,

Try this:

Code:
<table>
  <tr>
    <td>text always visible</td>
  </tr>

  <tr style=&quot;display:none;&quot; id=&quot;abc&quot;>
    <td>hidden text</td>
  </tr>

</table>

While IE does allow it, be aware that some browsers (like Netscape) do not allow you to change the &quot;display&quot; property value at runtime.

This could pose a problem for you if you need to show the hidden values with javascript. You could use &quot;visibility: hidden;&quot; instead (which can be changed at runtime), but that is not a perfect solution because the hidden box would still take up screen space.

I have not found a good solution around the above problem. Perhaps someone else has.

Anyway, I hope this helps.
-Ron

We all play from the same deck of cards, it's how we play the hand we are dealt which makes us who we are. -Me

murof siht edisni kcuts m'I - PLEH
 

>> While IE does allow it, be aware that some browsers (like Netscape) do not allow you to change the &quot;display&quot; property value at runtime

Yes it does. There are many, many posts over the last few weeks which do this perfectly well.

The DIV element in the original posting was invalid, as far as I can tell... You can't just place DIV tags anywhere - try validating the source.

Dan
 
Yes it does. There are many, many posts over the last few weeks which do this perfectly well.
This must be a relatively new thing for Netscape. I know that in the past it wasn't supported.

If it's now supported, I'm glad to hear it. That was a rather frustrating thing that I ran into on a couple occassions.

Thanks for setting the record straight Dan.

-Ron

We all play from the same deck of cards, it's how we play the hand we are dealt which makes us who we are. -Me

murof siht edisni kcuts m'I - PLEH
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top