select a range of dom elements based on index
<p>I need to select a specific grange of jquery elements based on there index using <code>:eq()</code> (or something else if you have a better solution)</p>

<p>my html structure is the following:</p>

<pre><code>&lt;ul&gt;
  &lt;li&gt;slide0&lt;/li&gt;
  &lt;li&gt;slide1&lt;/li&gt;
  &lt;li&gt;slide2&lt;/li&gt;
  &lt;li&gt;slide3&lt;/li&gt;
  &lt;li&gt;slide4&lt;/li&gt;
&lt;/ul&gt;
</code></pre>

<p>When the user hovers slides over the slide2 i need to select <code>li:eq(0), li:eq(1)</code> and <code>li:eq(3), li:eq(4)</code> separatly, because they have a different animation.</p>

<p>This is my solution, but this feels a little messy...</p>

<pre><code>var $slides, theOthers, slidesTotal;
$slides = $('ul &gt; li');
slidesTotal = $slides.length;
theOthers = function(slideIndex ,slidesTotal){
   var before = [], after = [], i=0;
   while (i&lt;=slideIndex - 1){
       before[i] = ":eq(" + i + ")"
       i++
   };
   while (i &lt;= slidesTotal) {
       after[i] = ":eq(" + i + ")"
       i++
   };
   return [ before.join(",") , after.join(",") ]
}

$slides.mouseenter(function(){
   var groups, slideIndex, $that = $(this);
   slideIndex = $that.index();
   groups = theOthers(slideIndex, slidesTotal);
   $slides.filter(groups[0]).dosomething();
   $slides.filter(groups[1]).dosomethingelse()
})
</code></pre>

<p>is there a more simple way to do this with jQuery?</p>
