隐藏并显示文字 [英] hide and show text
问题描述
你好,
我使用一个简单的表:
< TABLE>
< TR 1>
< TD>< / TD>
< / TR>
< TR 2>
< ; TD>< / TD>
< / TR>
< TR 3>
< TD>< / TD> ;
< / TR>
< / TABLE>
我希望在页面加载时隐藏第二个TR在图像上单击显示
。
我想避免使用document.write()方法。
我有尝试了hiden / visibility样式,但我得到的空间是TR 2假设
介于TR 1和TR 3之间。
有一个简单的方法吗这个?
非常感谢,
M.
Hello,
I use a simple Table :
<TABLE>
<TR 1>
<TD></TD>
</TR>
<TR 2>
<TD></TD>
</TR>
<TR 3>
<TD></TD>
</TR>
</TABLE>
and I would like to hide the second TR when the page load in order to show
it on an image click.
I would like to avoid document.write() method.
I have tried hiden/visibility style but I get spaces where TR 2 is suppose
to be between TR 1 and TR 3.
Is there a simple way to do this ?
Thanks a lot,
M.
推荐答案
" Michael Skind" < SK *** @ furrina.com>写道:
"Michael Skind" <sk***@furrina.com> writes:
我尝试过hiden / visibility样式,但我得到TR 2假设在TR 1和TR 3之间的空格。
I have tried hiden/visibility style but I get spaces where TR 2 is suppose
to be between TR 1 and TR 3.
尝试设置style.display =" none"隐藏和style.display =""再次显示
。
/ L
-
Lasse Reichstein Nielsen - < a href =mailto:lr*@hotpop.com> lr*@hotpop.com
DHTML死亡颜色:< URL:http://www.infimum.dk/ HTML / rasterTriangleDOM.html>
''没有判断的信仰只会降低精神神圣。''
Try setting style.display="none" to hide and style.display="" to show
it again.
/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
''Faith without judgement merely degrades the spirit divine.''
Michael Skind于2003年12月14日写道comp.lang.javascript :
Michael Skind wrote on 14 dec 2003 in comp.lang.javascript:
我使用一个简单的表:
< TABLE>
< TR 1>
< TD>< / TD>
< / TR>
< TR 2>
< TD>< / TD>
< / TR> ;
< TR 3>
< TD>< / TD>
< / TR>
< / TABLE>
我想当页面加载时隐藏第二个TR,以便在图像上单击显示它。
我想避免使用document.write()方法。
你不能忘记它,因为它会破坏你的页面和代码。
我有尝试了hiden / visibility样式,但我得到的空间是TR 2是假设在TR 1和TR 3之间。
I use a simple Table :
<TABLE>
<TR 1>
<TD></TD>
</TR>
<TR 2>
<TD></TD>
</TR>
<TR 3>
<TD></TD>
</TR>
</TABLE>
and I would like to hide the second TR when the page load in order to
show it on an image click.
I would like to avoid document.write() method.
You cannot NOt avoud that,
because it woud destroy your page AND the code.
I have tried hiden/visibility style but I get spaces where TR 2 is
suppose to be between TR 1 and TR 3.
< script>
函数hide(x){
document.getElementById(x).style.display =''none''
}
function show(x){
document.getElementById(x).style.display =''''
}
< / script>
< button
onclick =" hide(''tr2'')">
hide row 2
< / button>& nbsp;
< button
onclick =" show(''tr2'' )>>
显示第2行
< / button>< br>
< table border = 1>
< tr id = tr1>< td> ttttt< / td>< td> 1111111< / td>< / tr>
< tr id = tr2>< td> ttttt< / td>< t d> 222< / td>< / tr>
< tr id = tr3>< td> ttttt< / td>< td> 3< / td>< / tr>
< / table>
-
Evertjan。
荷兰。
(请在我的电子邮件地址中将x'变为点数)
<script>
function hide(x){
document.getElementById(x).style.display=''none''
}
function show(x){
document.getElementById(x).style.display=''''
}
</script>
<button
onclick="hide(''tr2'')">
hide row 2
</button>
<button
onclick="show(''tr2'')">
show row 2
</button><br>
<table border=1>
<tr id=tr1><td>ttttt</td><td>1111111</td></tr>
<tr id=tr2><td>ttttt</td><td>222</td></tr>
<tr id=tr3><td>ttttt</td><td>3</td></tr>
</table>
--
Evertjan.
The Netherlands.
(Please change the x''es to dots in my emailaddress)
Evertjan。写道:
Evertjan. wrote:
Michael Skind于2003年12月14日在comp.lang.javascript中写道 :
Michael Skind wrote on 14 dec 2003 in comp.lang.javascript:
我想避免使用文档。 write()方法。
你不能忽视它,
因为它会破坏你的页面和代码。
I would like to avoid document.write() method.
You cannot NOt avoud that,
because it woud destroy your page AND the code.
你的逻辑是,经过所有,非常有趣;-)
Your logic is, after all, quite interesting ;-)
我尝试了hiden / visibility样式但是我得到了空间,其中TR 2是
假设介于两者之间TR 1和TR 3.
I have tried hiden/visibility style but I get spaces where TR 2 is
suppose to be between TR 1 and TR 3.
< script>
<script>
< script type =" text / javascript"> ;
函数hide(x){
document.getElementById(x).style.display =''none''
}
function show(x){
document.getElementById(x).style.display =''''
}
这在语法和语义上都是正确的但是错误捕获
且效率低下。见< 3F ************** @ PointedEars.de>详情。
< / script>
[...]
<script type="text/javascript">
function hide(x){
document.getElementById(x).style.display=''none''
}
function show(x){
document.getElementById(x).style.display=''''
}
This is syntactically and semantically correct but error-catching
and inefficient. See <3F**************@PointedEars.de> for details.
</script>
[...]
PointedEars
PointedEars
这篇关于隐藏并显示文字的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!