div样式属性不起作用

时间:2014-04-10 19:34:42

标签: javascript html

我想在默认情况下隐藏div。

这应该很容易,我很沮丧为什么它不起作用。我做的是这个:

<div id="DivToHide" style="display: none;">
  <tr>
     <td>
        //calling some JSP taglibs that gets from a Java class controller
        <td width="169"><%= stockData %> </td>
     </td>
  </tr>
</div>

div继续出现在IE和Chrome中。怎么了?

1 个答案:

答案 0 :(得分:1)

嗯,错误的嵌套。见例:

<!DOCTYPE HTML>

<html>
    <head>
        <title>Untitled</title>
        <script>

        </script>
    </head>

    <body>
        <div style='display:none'>
            <table>
                <tr>
                    <td> You will not see this.? </td>
                </tr>
            </table>
        </div>
        <table>
            <div style='display:none'>
                <tr>
                    <td> Wrong nesting.  some browsers might show it, some others will hide it. </td>
                </tr>
            </div>
        </table>
    </body>
</html>