getElementById() 不能返回对象集合.
getElementsByName() 才可以.
但是<div>标签没有name属性的.

解决方案 »

  1.   

    replycount = reply.length; 
    是这个
    replycount = reply.innerHTML.length;
    ?
      

  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=gb2312" />
    <title>无标题文档</title>
    </head><body onload="GetReply()">
    <script type="text/javascript"> 
    var replycount = 0;
     
    function GetReply() 
    {
    var replys = document.getElementsByTagName("div");
    for(var i = 0;i < replys.length;i++) if(replys[i].id == "reply") replycount++
    alert(replycount); 
    } function Show(aid) 

    for ( i=0 ; i <replycount ; i++ ) 

    if(aid==i) reply[aid].style.display=""; 
    else reply[i].style.display="none"; 


    </script> 
    <form> 
    <div id="book1">留言1内容    <a href="#" id="0" onMouseMove="Show(this.id)">回复 </a> </div> 
    <div id="reply" style="display:none">回复1 </div> 
    <div id="book2">留言2内容    <a href="#" id="1" onMouseMove="Show(this.id)">回复 </a> </div> 
    <div id="reply" style="display:none">回复2 </div> 
    </form> 
    </body>
    </html>
      

  3.   

    <html><head>
    <meta http-equiv="Content-Type" content="text/html; charset=shift_jis">
    <title>新しいページ 1</title>
    <script type="text/javascript"> 
    var replycount; 
    function GetReply() 

    var reply = document.getElementById("reply");
    alert(reply.innerHTML) 
    replycount = reply.length; 
    alert(replycount); 
    } function Show(aid) 

    for ( i=0 ; i <replycount ; i++ ) 

    if(aid==i) 
    reply[aid].style.display=""; 
        else 
    reply[i].style.display="none"; 


    </script> 
    <BODY onload="GetReply()"> 
    <form> 
    <div id="book1">留言1内容    <a href="#" id="0" onMouseMove="Show(this.id)">回&#22797; </a> </div> 
        <div id="reply">1 </div> <div id="book2">留言2内容    <a href="#" id="1" onMouseMove="Show(this.id)">回&#22797; </a> </div> 
        <div id="reply">2 </div> 
    </form> 
    </BODY>你看看这个
    就明白了
      

  4.   

    哥们
    问题还没解决function Show(aid) 

        for ( a=0 ; a <replycount ; a++ ) 
        { 
            if(aid==a)
    {
    reply[aid].style.display="";
    document.getElementById("book" + aid).style.display="none";
    }else{
        reply[a].style.display="none";

        } 
    } 我的意思是说
        <div id="book1">留言1内容<a href="#" id="0" onMouseMove="Show(this.id)">回复 </a> </div> 
        <div id="reply" style="display:none">回复1 </div> 
        <div id="book2">留言2内容    <a href="#" id="1" onMouseMove="Show(this.id)">回复 </a> </div> 
        <div id="reply" style="display:none">回复2 </div> 当鼠标放到 “回复”上的时候
    这个时候
    相对应的只显示“回复1” id=book1 的DIV 要隐藏可目前的效果是 “回复1"显示出来了
    可是 ID=BOOK1 的div 内容也依然存在
      

  5.   

    看看这个<html>
    <head>
    <script type="text/javascript">
    function Show(o1,o2)
    {
    var   obj1=document.getElementById(o1);
    var   obj2=document.getElementById(o2);
    obj1.style.display='none';
    obj2.style.display='block';
    }
    function resetback(ob){document.getElementById(ob).style.display='block';
    }
    </script>
    </head>
    <BODY>
    <form>
    <div id="book1" onmouseover="Show('book1','book2');"   onmouseout="resetback('book1');">留言1内容    <a href="#" id="0">回复 </a> </div>
    <br><br><br><br><br><br>                               
    <div id="book2" onmouseover="Show('book2','book1');"   onmouseout="resetback('book2');">留言2内容    <a href="#" id="1">回复 </a> </div>
    </form>
    </BODY>
    </html>
      

  6.   

    以下测试通过:<!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=gb2312" />
    <title>无标题文档</title>
    </head><body onload="GetReply()">
    <script type="text/javascript"> 
    var replycount = 0;
     
    function GetReply() 
    {
    var replys = document.getElementsByTagName("div");
    for(var i = 0;i < replys.length;i++) if(replys[i].id == "reply") replycount++
    alert(replycount); 
    } function Show(aid) 

    for (i = 0;i <replycount;i++) 

    if(aid==i)
    {
    reply[aid].style.display = "";
    document.getElementById("book" + (i + 1)).style.display = "none";

    else
    {
    reply[i].style.display="none";
    document.getElementById("book" + (i + 1)).style.display = "";



    </script> 
    <form> 
    <div id="book1">留言1内容    <a href="#" id="0" onMouseMove="Show(this.id)">回复 </a> </div> 
    <div id="reply" style="display:none">回复1 </div> 
    <div id="book2">留言2内容    <a href="#" id="1" onMouseMove="Show(this.id)">回复 </a> </div> 
    <div id="reply" style="display:none">回复2 </div> 
    </form> 
    </body>
    </html>
      

  7.   

    你的两个DIV靠的太近,感觉不出效果,我加了几个换行。