只要将Table和input控件的Style的Display属性保持一至,应该能实现你所要求的.

解决方案 »

  1.   


    <body>
    <input type=button value="test可见?" onclick="alert(test.offsetLeft>0)">
    <input type=checkbox onclick="if(this.checked)font1.style.display='';else font1.style.display='none';"><br>
    <font id=font1 style="display:none">
    <input name=test value=1 >
    </font>
    </body>
      

  2.   

    1:不改变input的属性
    2:楼上的什么意思?
      

  3.   

    <table style="display:none">
    <tr><td>
    <input name="test1" type="text">
    </td></tr>
    </table>
    <button onclick="if(document.all.test1.clientWidth>0){alert('visible')}else{alert('unvisible')}">GetDisplay</button>
      

  4.   

    你所谓的不稳定是指的什么?我曾考虑过 currentStyle,取的 display 样式是 inline,不可以我可以再尝试一下
      

  5.   

    那你直接判断,table是否为none<input type=text name="txt1">
    <table style="display:none">
    <tr><td>
    <input type=text name="txt2">
    </td></tr>
    </table>
    <input type=text name="txt3">
    <script>
    function searchObjByTagName(obj,tag)
    {
       while(obj!=null && typeof(obj.tagName)!="undefind")
       {
         if(obj.tagName == tag.toUpperCase()) return(obj);
         obj = obj.parentElement;
       }
      return null;
    }
    function check(o)
    {
    if(searchObjByTagName(o,"TABLE").style.display=="none")alert("不可见");
    else alert("可见")
    }
    </script>
    <input type=button onclick="check(document.all.txt2)">
      

  6.   

    上面那个有点BUG,写了个通用一些的.
    <input type=text name="txt1" value="txt1">
    <table style="display:none">
    <tr><td>
    <input type=text name="txt2" value="txt2">
    </td></tr>
    </table>
    <table style="visibility:hidden">
    <tr><td>
    <input type=text name="txt3" value="txt3">
    </td></tr>
    </table>
    <input type=text name="txt4" value="txt4">
    <script>
    function IsSee(obj)
    {
       //函数:判断是否可见.原理,如果其父结点的display为none或visibility为hidden则其为不可见.
       //参数:要判断的对象.
       //返回:如果不可见.返回true;否则返回false;
       while(obj!=null && typeof(obj.tagName)!="undefind")
       {
         if(obj.style){if(obj.style.display=="none"||obj.style.visibility=="hidden")return true};
         obj = obj.parentElement;
       }
      return false;
    }
    function check(o)
    {
    if(IsSee(o))alert("不可见");
    else alert("可见")
    }
    </script>
    <input type=button onclick="check(document.all.txt1)" value="txt1">
    <input type=button onclick="check(document.all.txt2)" value="txt2">
    <input type=button onclick="check(document.all.txt3)" value="txt3">
    <input type=button onclick="check(document.all.txt4)" value="txt4">