这样吧,下面的例子:
<DIV id="myid">
<table border="1" cellpadding="0" cellspacing="0" width="100%" > <tr> <td>1</td> </tr></table>
<table border="1" cellpadding="0" cellspacing="0" width="100%" > <tr> <td>2</td> </tr></table>
<table border="1" cellpadding="0" cellspacing="0" width="100%" > <tr> <td>3</td> </tr></table>
<table border="1" cellpadding="0" cellspacing="0" width="100%" > <tr> <td>4</td> </tr></table>
<table border="1" cellpadding="0" cellspacing="0" width="100%" > <tr> <td>5</td> </tr></table></DIV>
<input type=button value="展开所有table" onclick="show('show')">
<input type=button value="关闭所有table" onclick="show('hidden')"> 请问,这个show函数怎么写?
<DIV id="myid">
<table border="1" cellpadding="0" cellspacing="0" width="100%" > <tr> <td>1</td> </tr></table>
<table border="1" cellpadding="0" cellspacing="0" width="100%" > <tr> <td>2</td> </tr></table>
<table border="1" cellpadding="0" cellspacing="0" width="100%" > <tr> <td>3</td> </tr></table>
<table border="1" cellpadding="0" cellspacing="0" width="100%" > <tr> <td>4</td> </tr></table>
<table border="1" cellpadding="0" cellspacing="0" width="100%" > <tr> <td>5</td> </tr></table></DIV>
<input type=button value="展开所有table" onclick="show('show')">
<input type=button value="关闭所有table" onclick="show('hidden')"> 请问,这个show函数怎么写?
解决方案 »
- 新手 急求
- 请问如何判断ocx控件在页面加载是否成功?
- JSP用javabean的时候一直说找不到类?
- 浏览器对于js文件的缓存策略是什么?有什么办法可以在html中控制缓存吗?
- 请问radio的input怎么判断?
- 在框架中的左框架调用模态窗口,怎么样让模态窗口关闭时,左框架执行一个struts的action
- 怎么做到在点击一个链接后,一段时间内再点击的话就没用....
- <a href=\"moreshou.asp?ttt=<%=rs("ttt")%> ...请教\"
- 帮忙解释一下这段代码.谢!
- 能否设定使表单中的某个域不提交?
- 请问htc中,PROPERTY 的INTERNAME属性怎么用啊?
- 如何制作一个能弹出的层?
<script language="JavaScript">
<!--
function show(flag){
var c=document.getElementById("myid").childNodes
for(i=0;i<c.length;i++)c[i].style.display=flag
}
//-->
</script>
<DIV id="myid">
<table border="1" cellpadding="0" cellspacing="0" width="100%" > <tr> <td>1</td> </tr></table>
<table border="1" cellpadding="0" cellspacing="0" width="100%" > <tr> <td>2</td> </tr></table>
<table border="1" cellpadding="0" cellspacing="0" width="100%" > <tr> <td>3</td> </tr></table>
<table border="1" cellpadding="0" cellspacing="0" width="100%" > <tr> <td>4</td> </tr></table>
<table border="1" cellpadding="0" cellspacing="0" width="100%" > <tr> <td>5</td> </tr></table>
</DIV>
<input type=button value="展开所有table" onclick="show('block')">
<input type=button value="关闭所有table" onclick="show('none')">
{
eval(document.all(ok)).style.display=(eval(document.all(ok)).style.display=="none")?"":"none";
}function closeall()
{
for (i=1;i<=6;i++) {
document.all("layer"+i).style.display="none";
}
}
</script>
<DIV id="layer1">层1</DIV>
<DIV id="layer2">层2</DIV>
<DIV id="layer3">层3</DIV>
<DIV id="layer4">层4</DIV>
<DIV id="layer5">层5</DIV>
<DIV id="layer6">层6</DIV>
<DIV id="ok" name="kkk">上面的...</DIV>
<br>
<input type=button value="打开或关闭层3" onClick="show('layer3');">
<input type=button value="关闭所有的层" onClick="closeall();">
<input type=button value="打开层3并关闭其它所有的层" onClick="closeall();show('layer3')">
<head>
<script language="javascript">function show(ok) //????
{
document.all(ok).style.display=document.all(ok).style.display==""?"none":"";
}function closeall()
{
for (i=1;i<7;i++) {
document.all("layer"+i).style.display="none"; //???
}
}function myopen(ok2)
{
for (i=1;i<7;i++) {
document.all("layer"+i).style.display="none"; //???
}
document.all(ok2).style.display="";
}</script>
</head><body>
<DIV id="layer1">层1</DIV>
<DIV id="layer2">层2</DIV>
<DIV id="layer3">层3</DIV>
<DIV id="layer4">层4</DIV>
<DIV id="layer5">层5</DIV>
<DIV id="layer6">层6</DIV>
<DIV id="ok" name="kkk">上面的...</DIV>
<br>
<input type=button value="打开或关闭层3" onClick="show('layer3');">
<input type=button value="关闭所有的层" onClick="closeall();">
<input type=button value="打开层3并关闭其它所有的层" onClick="myopen('layer3');">
</body>
</html>