|
Re: [jQuery] The index of an element with Event: msg#01160lang.javascript.jquery
BoOz schrieb: > 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 > > $("a[@rel='enclosure'][@href$=mp3]").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 ? > How about this: var links = $("a[@rel='enclosure'][@href$=mp3]"); links.click(function(e) { var indexOfThisLink = links.index(this); // other stuff }); -- Jörn
|
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | Re: [jQuery] Mimetype option for $.ajax, Ⓙⓐⓚⓔ |
|---|---|
| Next by Date: | Re: [jQuery] Form plugin revisited ;-), Jörn Zaefferer |
| Previous by Thread: | Re: [jQuery] The index of an element with Event, BoOz |
| Next by Thread: | [jQuery] IE bookmarklet problems, Chad Jackson |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
| News | FAQ | advertise |