obj = h1;
while ((obj = obj.nextSibling) != null) {
if (obj.tagName == "DIV")
return obj;
}

解决方案 »

  1.   

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <script>
    function func(){
    var obj = document.getElementById("h");
    while(obj = obj.nextSibling){
    if(obj.tagName == "DIV"){
    alert(obj.id);
    }
    }
    }
    </script>
    <title>首页 </title></head>
    <body onLoad="func()">
    <div id="d1"></div>
    <h1 id="h"></h1>
    <img id="i1">
    <div id="d2"></div>
    </body>
    </html> 
      

  2.   


    http://www.scriptlover.com/post/385