On 13/10/06, BoOz <[EMAIL PROTECTED]> wrote:
> Hello,
>
> I can't figure out how to accès the index of the élément that is clicked.
>
> Let's say I have 4 mp3 links in the page and that I click the second one
> , I can acces the url of the link that is clicked like this
>
> $("[EMAIL PROTECTED]'enclosure'[EMAIL PROTECTED]").bind("click",function(e){
> alert(this.href);
> e.stopPropagation();
> return false;
> });
>
> But how can I know that it is the second link that is cliked, i.e the
> index of this link beyond all links ?
>
> Sorry for my poor english ;)
>
> PS : I'm working on a jQuery + Aflax mp3 player :)
>
> BoOz
At the moment I think the callback function only has one argument (the
event), perhaps jQuery in the future may be able to have another one
indicating the index.
You can workaround this though usign each:
$("a").each(
function(i)
{
$(this).click(
function(e)
{
e.preventDefault();
alert("item " + i + " clicked with href = " + this.href);
}
)
}
);
_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/