jQuery each() non-blocking?
<p>Is jQuery's each() function non-blocking?</p>

<p>In the below example, I expect "test in each" to be logged first, but in each test "test out of each" is logged first.</p>

<p>So this is causing the loop to run up to the body (sometimes the document) element before returning an error.</p>

<p>I'm just trying to get a common parent to wrap or if the two elements (firstp and lastp) are the siblings, then wrap those.</p>

<p>But, I'm mostly curious about the performance of the each() function and whether it is non-blocking.    </p>

<pre><code>while(firstp[0] !== lastp[0]){
        //If parents are siblings, this will do for wrapping.
        var isS = false;
            firstp.siblings().each( function(index, el){
                console.log("test in each");
                if(jQuery(el)[0] === lastp[0]){
                    isS = true;
                    return true;
                }
            });
            console.log("test out of each");
        if(isS === true){ break; }
        firstp = firstp.parent();
        lastp = lastp.parent();
    }
</code></pre>

<p>EDIT:</p>

<p>Sorry guys.  This was a false alarm.  Paul is correct.  My HTML actually had two elements that was matching for firstp.  I didn't realize this, so the first one did not have a sibling, causing the error.  I was looking at the second element the whole time.</p>

<p>But, I did learn something in the process, so thanks for taking the time to answer.</p>
