如何判断控件的可见性************** 只要将Table和input控件的Style的Display属性保持一至,应该能实现你所要求的. 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 <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> 1:不改变input的属性2:楼上的什么意思? <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> 你所谓的不稳定是指的什么?我曾考虑过 currentStyle,取的 display 样式是 inline,不可以我可以再尝试一下 那你直接判断,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)"> 上面那个有点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"> Jquery 中AJAX的问题 JS 怎么判断一个 url是否可用 js文件可以直接执行aspx文件么? 关于Dtree 未何设置了position:absolutes 的<ul> 该<ul>还是会运动 为啥在firefox下显示不出效果阿 如何改变网页中的所有内容 netscape下,在后台写的window.open()为什么不执行? 高分求一份关于网页制作的文章 怎样实现页面全屏 如何去掉用window.showModalDialog打开的窗口的标题栏? 请教高手:如何在页面上对一个按钮或者链接实现类似于Window Form程序中的hint?
<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:楼上的什么意思?
<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>
<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)">
<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">