JQuery prevent removing class if first or last child?
<p>I have a class 'active' that is constantly being removed and added to other divs. But I don't want it removed if it is applied to a first or last child...</p>

<p>JSFiddle: <a href="http://jsfiddle.net/YuDDK/1/" rel="nofollow">http://jsfiddle.net/YuDDK/1/</a></p>

<p>HTML:</p>

<pre><code>&lt;div id="container"&gt;
&lt;div class="item active"&gt;&lt;/div&gt;
&lt;div class="item"&gt;&lt;/div&gt;
&lt;div class="item"&gt;&lt;/div&gt;
&lt;div class="item"&gt;&lt;/div&gt;
&lt;/div&gt;
</code></pre>

<p>JS:</p>

<pre><code>$('#container').mousewheel(function(event, delta) {
    var active = $('.active');

    if (delta &gt; 0) {
        if (active.not(":first-child")) {
            active.removeClass('active').prev().addClass('active');
        }

    } else {
        if (active.not(":last-child")) {
            active.removeClass('active').next().addClass('active');
        }
    }

    $(this).scrollTo( $('.active'),100);
    return false;
});
</code></pre>
