Jquery .each() - return value undefined
<p>Why getColorOptionSelect() return undefined value (I'm sure it has a value by debugger ).</p>

<p>It is for sure an issue related to the scope, sorry for my js ignorance </p>

<pre><code>jQuery(document).ready(function () {

    colorSelectID = getColorOptionSelect();
    alert(colorSelectID);

    function getColorOptionSelect() {

        // get label
        var selId;
        jQuery(".product-options dl label").each(function () {
            el = jQuery(this);
            // lower case, remove *
            var labelText = el.text().toLowerCase().replace("*", "");
            if (labelText == 'color') {
                //return element
                selId = el.parent().next().find("select").attr('id');
                return selId;
            }
        });
        //    return null;
    }

});
</code></pre>
