# findChild

**URL:** <https://forum.kirupa.com/t/findchild/212487>\
**Category:** Uncategorized\
**Created:** [January 11, 2007, 2:00pm UTC](https://forum.kirupa.com/t/findchild/212487 "2007-01-11T14:00:05Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![CodeLegion](https://avatars.discourse-cdn.com/v4/letter/c/ed655f/32.png) [@CodeLegion](https://forum.kirupa.com/u/CodeLegion)\
**Post date:** [January 11, 2007, 2:00pm UTC](https://forum.kirupa.com/t/findchild/212487/1 "2007-01-11T14:00:05Z")

</div>

Hi guys, just wondering if someone would be kind enough to help me understand how this bit of javascript works below.

```auto

function findChild (element, nodeName)
{
    var child;
    
    for (child = element.firstChild; child != null; child = child.nextSibling)
    {
        if (child.nodeName == nodeName)
            return child;
    }
    
    return null;
}

```

I know what it basically does, but im having trouble running it through in my head clearly, as in talk it through too myself. Its apart of XML feed parser for a RSS widget i’m learning.

The for loop is what is confusing me I guess, specifically the variable and incrementing factor (child=child.nextSibling).

Any help would be greatly appreciated.

Thanks in advance.

Legion.
