Consider this JavaScript:
var number = $(".linksMiniImages a").index(this);
alert (number);
Alert shows -1 when I click on a link.
What could be wrong?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
When you run that
thiswill be referring to something other than theaelement, most likelywindow.If you simply remove the
thisfrom your code it should behave as expected: http://jsfiddle.net/Zikes/2kFJt/Alternatively, this may be what you’re after:
http://jsfiddle.net/Zikes/frBa8/1/