Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Regular Coder
    Join Date
    Nov 2002
    Posts
    567
    Thanks
    2
    Thanked 4 Times in 4 Posts

    A collection of Divs?

    I would like to run a javascript for loop for each div that is within a containing div. Is there a way to identify the contained divs?
    Scott Stewart
    Always happy to learn from pros.

  • #2
    Master Coder
    Join Date
    Feb 2003
    Location
    Umeå, Sweden
    Posts
    5,575
    Thanks
    0
    Thanked 83 Times in 74 Posts
    getElementsByTagName is a method of all Element objects, so you can do somehting like this:
    var cDivs=document.getElementById('yourContainerDiv').getElementsByTagName('div');
    liorean <[lio@wg]>
    Articles: RegEx evolt wsabstract , Named Arguments
    Useful Threads: JavaScript Docs & Refs, FAQ - HTML & CSS Docs, FAQ - XML Doc & Refs
    Moz: JavaScript DOM Interfaces MSDN: JScript DHTML KDE: KJS KHTML Opera: Standards

  • #3
    Regular Coder
    Join Date
    Nov 2002
    Posts
    567
    Thanks
    2
    Thanked 4 Times in 4 Posts
    Thanks Liorean,

    I have just today been able to get back to my toy. Work has prevented me from doing useful things.

    Looking at a collection of my posts one can see that divs give me a lot of trouble. I either can't get a reference to one, can't get the css to apply to one, I've got them hiding behind other content, or some such thing.

    I finally got the divs to line up properly and was able to identify each one with code. Now I can work on getting my popup div from hiding behind the xml document being displayed.

    I appreciate your help.
    Scott Stewart
    Always happy to learn from pros.


  •  

    Posting Permissions

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