jQuery - Can access an element's class on one line, can't on the next
<p>This is from a section of a much more complicated script. In short, I'm trying to do 2 things here:</p>

<ol>
<li>Get an element's children's class names, and remove the word "span" from them, then add them to a variable (this works fine).</li>
<li>Get those class names (in full, with 'span' still attached) and add them to an array.</li>
</ol>

<p>Here's my code:</p>

<pre><code>var currentSpans = [];

$('container').children().each(function(i2, spans) {
    if (spans.className.indexOf('span') != -1) {
        total += parseInt(spans.className.replace(/[A-Za-z$-]/g, ""),10);
        currentSpans.push(spans.attr('class'));
    }

});
</code></pre>

<p>It breaks at <code>currentSpans.push(spans.attr('class'));</code> and says <code>#&lt;HTMLDivElement&gt; has no method 'attr'</code></p>

<pre><code>        currentSpans.push(spans.className());
</code></pre>

<p>as it was used above, but here it doesn't work (this was expected though).</p>

<p>What am I doing wrong here? It seems like a simple enough problem but I'm coming up blank, might be because I've been working with jquery all day!</p>
