怎样点击其中一个DIV(层),隐藏其它DIV(层)???

解决方案 »

  1.   

    Dreamweaver里手动操作可以自动生成代码。
      

  2.   

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>shawl.qiu template</title>
    <script type="text/javascript">
    //<![CDATA[
     onload=function()
     {
      var oDiv=document.getElementById("main").getElementsByTagName("div");
      for(var i=0, j=oDiv.length; i<j; i++)
      {
       oDiv[i].onclick=function()
       {
        fHdOth(this);
       }
      }
     }
     
     function fHdOth(oDiv)
     {
      var oDivRg=oDiv.parentNode.getElementsByTagName("div");
      for(var i=0, j=oDivRg.length; i<j; i++)
      {
       if(oDiv==oDivRg[i])continue;
       oDivRg[i].style.display="none";
      }
     } // shawl.qiu script
    //]]>
    </script>
    </head>
    <body>
    <div id='main'>
     <div>1</div>
     <div>2</div>
     <div>3</div>
     <div>4</div>
     <div>5</div>
    </div>
    </body>
    </html>
      

  3.   

    这个问题和你的一样,
    http://community.csdn.net/Expert/topic/5335/5335616.xml?temp=.1560633
    参看解答