Script not running jquery .each
<p>This is a snippet from a puzzle game I'm trying to develop. The problem is it stops working after <code>each()</code> of jquery is called. Please help me figure out the problem. Thanks in advance.</p>

<pre><code>    function setTotalInPositionPieces()
    {
        $("#board").children('div').each(function(index, element) {
            if(testInPosition(element))
            {
                ++totalInPositionPieces;
                $(element).attr("data-inPositionStatus", '1');
            }
        });

    /* The script does not from here, onward. Please tell 
me what is the problem. Thanks in advance.*/

        if(totalInPositionPieces == totalPieces)
        {
            $("#messageBox").text("Puzzle Solved!");
        }
    }
</code></pre>

<p><code>totalInPositionPieces</code> and <code>totalPieces</code> are global variables.</p>
