Getting all children of an element

Discussion in 'Javascript' started by Andrej Pavlovic, Apr 8, 2007.

  1. Hi,

    Please look at the following HTML snippet:

    <body>
    some text
    <p>more text</p>
    even more text
    </body>

    The value of document.body.children.length would be 1. The one child
    is the <p> tag. Now what I want is to be able to get the children of
    body including the text elements.

    So essentially there would be 3 children of body: 'some text', <p>,
    'even more text'. How can I do this?

    Thank you in advance!
     
    Andrej Pavlovic, Apr 8, 2007
    #1
    1. Advertisements


  2. document.body.childNodes.length
     
    Andrej Pavlovic, Apr 8, 2007
    #2
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.