I wanted to avoid putting id's on them, also an id has to start with a
letter.
I've just done this, and it works charmingly
var eq = $(this).parent().children("a").index(this);
MorningZ wrote:
":eq" is a selector, not a property (certainly a BIG difference)
i'm not sure how you expected anything but nothing from
var eq = $(this).eq();
do your links have IDs on them?if they did then:
this.children("a").click(function() {
var idx = -1;
var LinkId = $(this).id;
$(this).parent().children("a").each(function(i) {
if ($(this).id == LinkId) {
idx = i;
break;
}
});
// idx = -1: didn't find... otherwise it's the 0 based index of
the link clicked
});
(i'm sure it's easier using "siblings" rather than going up to parent
and down to children "a" tags, but i'm running late this morning and
don't have time to research that... also not sure if "> a" is a
valid selector, but you should )
On Feb 26, 7:56 am, Liam Potter wrote:
Hi,
I'm trying to find the index of a click element
this doesn't work (specifically the eq part, rest is fine)
this.children("a").click(function() {
var eq = $(this).eq();
console.log(eq);
$(this).parents(".thumbnails").children(".current").animate({left:
""+eq*currentSlide+"px"},opts.fadeOut);
return false;
});
how would I find the index, as this is returning nothing.
- Liam