How to add a class to a list item using jQuery
<p>I have a vertical list where I am storing the current selected items index in a PHP session variable.</p>

<p>Now, when I come back to the same page, I want to apply a CSS Class to that particular list item.</p>

<p>Not sure how to set the class of a particular index in a list using jQuery.</p>

<p>I am doing something like this:</p>

<pre><code>$('ul.selectable1 li').get(3).addClass('myselection');
</code></pre>

<p>The UL >li list has a class attached to it called "selectable1:</p>

<pre><code>&lt;ul id="items" class="selectable1"&gt;
  &lt;li&gt;Item 1&lt;/li&gt;
  &lt;li&gt;Item 2&lt;/li&gt;
  &lt;li&gt;Item 3&lt;/li&gt;
  &lt;li&gt;Item 4&lt;/li&gt;
  &lt;li&gt;Item 5&lt;/li&gt;
  &lt;li&gt;Item 6&lt;/li&gt;
&lt;/ul&gt;
</code></pre>

<p>So if the Item-3 was stored in my session. I would like to make the list appear like this:</p>

<pre><code>&lt;ul id="items" class="selectable1"&gt;
  &lt;li&gt;Item 1&lt;/li&gt;
  &lt;li&gt;Item 2&lt;/li&gt;
  &lt;li class="myselection"&gt;Item 3&lt;/li&gt;
  &lt;li&gt;Item 4&lt;/li&gt;
  &lt;li&gt;Item 5&lt;/li&gt;
  &lt;li&gt;Item 6&lt;/li&gt;
&lt;/ul&gt;
</code></pre>
