dynamically changing class
<p>I have a lot of items of same class <code>“first”</code></p>

<ul>
<li>I want to keep the class of the first item as such without change</li>
<li>I want to make the class of the last item to “last” </li>
<li>I  want to  remove class of the  all items  between first and last.</li>
</ul>

<p>I have tried:</p>

<pre><code>var mailHeadding = $('.first');
$.each(mailHeadding, function (indx) {
    if (indx == mailHeadding.length) {
        mailHeadding[indx].removeClass('first').addClass('last');
    }
    else if (indx != 0) {
        mailHeadding[indx].removeClass('first');
    }
});
</code></pre>

<p>Also <code>mailHeadding[indx]</code> replaced by <code>"this"</code></p>

<p>Still this won't work.</p>
