JavaScript "unexpected identifier" in each loop - Why am I getting this error? Simple demo code within
<pre><code>function printClassForAllDivs()
{
    var divs = $('div');
    divs.each(function{
        var klass = $(this).attr('class');
        console.log('div class = '+klass);
    });
}
</code></pre>

<p>It seems to me that this code should loop over all the divs and for each iteration of the loop a variable should be created to store the class, which is then printed to the console.</p>

<p>I'm afraid I don't understand something about how to use the anonymous function.</p>

<pre><code>function printClassForAllDivs()
{
    var divs = $('div');
    divs.each(function{
        // what don't I understand about what I am permitted to do in here?
    });
}
</code></pre>

<p>Thanks.</p>
