www.webdeveloper.com
Results 1 to 2 of 2

Thread: getting access to dom elements

  1. #1
    Join Date
    Jul 2004
    Posts
    329

    getting access to dom elements

    Hello

    Assume I have the following HTML tags:
    Code:
    <div id="container"
     <div id="a" />
     <div id="b" />
     <div id="c">
       <div id="d" />
     </div>
     <div id="e" />
    </div>
    I need to write a JavaScript code that does the following:
    Get a reference to the "container" element
    get an array of all its direct children

    Iterate over its children array and print their id value
    In the example above, the direct children would be:
    a, b, c and e

    Note the d is left out because it is not a direct child of the "container"

    I need the code to run on both IE and Firefox
    I need a solution that will work even if the container's direct children are not div elements, but any html tags

    any help would be appreciated

  2. #2
    Join Date
    Nov 2003
    Location
    Worthington, OH, USA
    Posts
    3,634
    Attached is something I wrote sometime back to explore the DOM on IE and let me compare it to what I could get from the DOM Inspector in FF. It runs on both and should be a little more than what you're asking for.
    Attached Files Attached Files
    54 68 65 42 65 61 72 4D 61 79

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles