问这样的问题最好先准备一个基本的demo,方便修改调试,什么都要回答的人重头写也够累的。

解决方案 »

  1.   


    <html><head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    <title>显示div</title>
    <script>
    function showDiv(o,id)
    { var o2 = document.getElementById(id);
    if(o2.style.display=="none")
    {
    o2.style.display="";
    o.innerText = "隐藏DIV";
    }
    else
    {
    o2.style.display="none";
    o.innerHTML= "显示DIV";
    }
    }
    </script>
    </head><body>
    <div onclick="showDiv(this,'div1')" style="cursor:hand">隐藏div</div>
    <div id="div1">我被显示</div>
    </body></html>
      

  2.   

    style="cursor:hand"
    hand可以改成pointer
      

  3.   

    非常感谢。  在firefox下,显示div和隐藏div的切换好像有问题,
      

  4.   

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" 
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
    <meta http-equiv="Content-Language" content="gb2312" />
    <title>DY CSS Layout</title>
    <meta name="Author" content="Doyoe(飘零雾雨), [email protected]" />
    <script type="text/javascript">
    function display(){
    var obj1 = document.getElementById("test");
    obj1.style.display = (obj1.style.display == "none")?"block":"none";
    }
    </script>
    </head>
    <body>
    <div><a id="dj" href="javascript:void(0);" onclick="display();">隐藏/显示</a></div><p id="test">我是大段的文字</p>
    </body>
    </html>
      

  5.   

    Firefox 不支持 innerText / innerHTML