日期:2014-05-16 浏览次数:20384 次
<html> <head> <meta http-equiv="Content-Type" content="text/html;charset=gb2312"> <title>使用脚本(JavaScript)实现同一个页面中的多个层(div)同时只显示指定的一个</title> </head> <body> <Script Language="JavaScript"> <!-- function GuDIVShowHidden(GuDIVShowHiddenA,GuDIVShowHiddenB,GuDIVShowHiddenC,GuDIVShowHiddenD,GuDIVShowHiddenE,GuDIVShowHiddenF) { if (GuDIVShowHiddenA.style.display=="none") { GuDIVShowHiddenA.style.display=""; if (GuDIVShowHiddenB!=null) { GuDIVShowHiddenB.style.display="none"; } if (GuDIVShowHiddenC!=null) { GuDIVShowHiddenC.style.display="none"; } if (GuDIVShowHiddenD!=null) { GuDIVShowHiddenD.style.display="none"; } if (GuDIVShowHiddenE!=null) { GuDIVShowHiddenE.style.display="none"; } if (GuDIVShowHiddenF!=null) { GuDIVShowHiddenF.style.display="none"; } } else { GuDIVShowHiddenA.style.display="none"; if (GuDIVShowHiddenB!=null) { GuDIVShowHiddenB.style.display="none"; } if (GuDIVShowHiddenC!=null) { GuDIVShowHiddenC.style.display="none"; } if (GuDIVShowHiddenD!=null) { GuDIVShowHiddenD.style.display="none"; } if (GuDIVShowHiddenE!=null) { GuDIVShowHiddenE.style.display="none"; } if (GuDIVShowHiddenF!=null) { GuDIVShowHiddenF.style.display="none"; } } } //--> </Script> <input type="button" name="Button_DIV_1" onclick="JavaScript:GuDIVShowHidden(GuDIV_1,GuDIV_2,GuDIV_3,GuDIV_4,GuDIV_5,GuDIV_6);" value="显示/隐藏第一个层,同时关闭其它的层"><br> <input type="button" name="Button_DIV_2" onclick="JavaScript:GuDIVShowHidden(GuDIV_2,GuDIV_1,GuDIV_3,GuDIV_4,GuDIV_5,GuDIV_6);" value="显示/隐藏第二个层,同时关闭其它的层"><br> <input type="button" name="Button_DIV_3" onclick="JavaScript:GuDIVShowHidden(GuDIV_3,GuDIV_1,GuDIV_2,GuDIV_4,GuDIV_5,GuDIV_6);" value="显示/隐藏第三个层,同时关闭其它的层"><br> <input type="button" name="Button_DIV_4" onclick="JavaScript:GuDIVShowHidden(GuDIV_4,GuDIV_1,GuDIV_2,GuDIV_3,GuDIV_5,GuDIV_6);" value="显示/隐藏第四个层,同时关闭其它的层"><br> <input type="button" name="Button_DIV_5" onclick="JavaScript:GuDIVShowHidden(GuDIV_5,GuDIV_1,GuDIV_2,GuDIV_3,GuDIV_4,GuDIV_6);" value="显示/隐藏第五个层,同时关闭其它的层"><br> <input type="button" name="Button_DIV_6" onclick="JavaScript:GuDIVShowHidden(GuDIV_6);" value="显示/隐藏第六个层,其它层不影响"> <br> <br> <div id="GuDIV_1" style="display:none">第一个层</div> <div id="GuDIV_2" style="display:none">第二个层</div> <div id="GuDIV_3" style="display:none">第三个层</div> <div id="GuDIV_4" style="display:none">第四个层</div> <div id="GuDIV_5" style="display:none">第五个层</div> <div id="GuDIV_6" style="display:none">第六个层</div> </body> </html>