title: Detect if a link has been clicked and apply a different CSS class if it has
body: <p>So what I want to do is determine if the current link is 'active', i.e. if this link was just clicked by the user.</p>
  
  <p>If it is, then I want to apply the <code>class=selected</code> to that <code>&lt;li&gt;</code> item.</p>
  
  <p>So this is what I am working with:</p>
  
  <pre><code>&lt;ul&gt;
     &lt;li&gt;&lt;a href="#"&gt;Link 1&lt;/a&gt;&lt;/li&gt;
     &lt;li&gt;&lt;a href="#"&gt;Link 2&lt;/a&gt;&lt;/li&gt;
     &lt;li&gt;&lt;a href="#"&gt;Link 3&lt;/a&gt;&lt;/li&gt;
     &lt;li&gt;&lt;a href="#"&gt;Link 4&lt;/a&gt;&lt;/li&gt;
     &lt;li&gt;&lt;a href="#"&gt;Link 5&lt;/a&gt;&lt;/li&gt;
  &lt;/ul&gt;  
  </code></pre>
  
  <p>If a link is selected, I want the <code>&lt;li&gt;</code> to look like this:</p>
  
  <p><code>&lt;li class="selected"&gt;&lt;a href="#"&gt;Link 1&lt;/a&gt;&lt;/li&gt;</code></p>
  
  <p>So the only differences is that one has a class applied to it, and the other doesn't.</p>
  
  <p>I want to do this in an <code>erb</code> file. So Ruby would be the language of choice...although, it's not Rails (Sinatra to be exact).</p>
  
  <p>Thanks.</p>
  
  <p><strong>Edit 1</strong></p>
  
  <p>Using jQuery might be necessary and that will be fine.</p>