What is the most jquery-y way to get the numeric position of an element in a list?
<p>I want to get the index of an item in a list like similar to this:</p>

<pre><code>&lt;ul&gt;
    &lt;li&gt;Option 1&lt;/li&gt;
    &lt;li class="selected"&gt;Option 2&lt;/li&gt;
    &lt;li&gt;Option 3&lt;/li&gt;
&lt;/ul&gt;

// doesn't work
var selected = #('ul#options li').index('.selected');
// selected should == 1
</code></pre>

<p>I could do it with</p>

<pre><code>var selected = -1;

$('ul#options li').each(function(a, li){
    if($(li).hasClass('selected')){
        selected = $(li).parent().children().index(li);
    }
});
// selected == 1
</code></pre>

<p>but it seems like there has to be a cooler/more concise way to accomplish this.</p>

<p>EDIT:</p>

<p>I came up with </p>

<pre><code>$('ul#options li').index($('ul#options li.selected'));
</code></pre>

<p>which is better. It turns out .index() needs an object not just a selector string.</p>
