遍历Div

<!DOCTYPE   HTML   PUBLIC   "-//W3C//DTD   HTML   4.01   Transitional//EN ">
<html>
    <head>
    <meta   http-equiv= "content-type "   content= "text/html;   charset=windows-1250 ">
    <meta   name= "generator "   content= "PSPad   editor,   www.pspad.com ">
    <title> </title>
    <script   language=javascript>
        window.onload=function(){
            var   o=document.getElementById( "a ");
            var   eles=o.childNodes;
            //alert(eles.length);
            for(var   i=0;i <eles.length;i++){
                var   e=eles[i].childNodes[0];
                alert(e.data);
                //for(var   p   in   e){
                //     alert(   p+ ": "+e[p]);
                //}
            }
       
        }
    </script>
    </head>
    <body ">
<div   id= "a ">
<p>   Node   in   p </p>
<h1> node   in   h1 </h1>

</div>
    </body>
</html>

posted @ 2008-04-24 11:40  南守拥  阅读(862)  评论(0编辑  收藏  举报