Getting the clicked element using $(this)
<p>hey I have this silly issue and I hope you could help me to solve it. I have some "a" elements and I just want to add an active class when clicked.</p>

<p>I tried this :</p>

<pre><code>&lt;a href="javascript:mifunction()"&gt;&lt;/a&gt;

js:
function mifunction(){
 $(this).addClass('active');
}
</code></pre>

<p>but it doesn't work, so I tried this:</p>

<pre><code>&lt;a&gt;&lt;/a&gt;

js:
$('a').click(function() {
  $(this).addClass('active');               
});
</code></pre>

<p>It doesn't work either. It just worked when I mixed both. But users have to dubbleclick the element, which is not an option:</p>

<pre><code>&lt;a href="javascript:mifunction()"&gt;&lt;/a&gt;
js:

function mifunction(){
 $('a').click(function() {
   $(this).addClass('active');              
 });
}
</code></pre>

<p>Do you have any idea of how to solve this?</p>

<p>Thank you very much!</p>
