Getting the clicked element using $(this)
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.

I tried this :
    
    <a href="javascript:mifunction()"></a>

    js:
    function mifunction(){
     $(this).addClass('active');
    }
 but it doesn't work, so I tried this:
    
    <a></a>
   
    js:
    $('a').click(function() {
      $(this).addClass('active');			    
    });
It doesn't work either. It just worked when I mixed both. But users have to dubbleclick the element, which is not an option:
    
    <a href="javascript:mifunction()"></a>
    js:
    
    function mifunction(){
     $('a').click(function() {
       $(this).addClass('active');			    
     });
    }

Do you have any idea of how to solve this?

Thank you very much!
 
Getting the clicked element using $(this)
===

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.

I tried this :
    
    <a href="javascript:mifunction()"></a>

    js:
    function mifunction(){
     $(this).addClass('active');
    }
 but it doesn't work, so I tried this:
    
    <a></a>
   
    js:
    $('a').click(function() {
      $(this).addClass('active');			    
    });
It doesn't work either. It just worked when I mixed both. But users have to dubbleclick the element, which is not an option:
    
    <a href="javascript:mifunction()"></a>
    js:
    
    function mifunction(){
     $('a').click(function() {
       $(this).addClass('active');			    
     });
    }

Do you have any idea of how to solve this?

Thank you very much!
 