View Single Post
06-05-2012, 06:08 PM
#1
Dan is offline Dan
Dan's Avatar
Status: Request a custom title
Join date: Feb 2005
Location:
Expertise:
Software:
 
Posts: 3,164
iTrader: 15 / 86%
 

Dan is an unknown quantity at this point

  Old  jQuery: Selecting clicked element?

I have:

HTML Code:
<a href=# class=star>star</a> 
<a href=# class=star>star</a>
<a href=# class=star>star</a>
<a href=# class=star>star</a>
<a href=# class=star>star</a>
<a href=# class=star>star</a>
<a href=# class=star>star</a>
How can I target the element that is clicked?

I've tried:

Code:
$("a.star").click(function() {

var index = $(this).index();
index.addClass("fave");
But it doesn't work in this case. =(