I\'m confused as to why .index() is returning 0 in this code. Shouldn\'t it return the index of where it\'s found in the array of jquery objects?
Another reason that .index()
could return 0
is if you are using it like so:
$('matched elements').click(function(){
console.log($(this).index()); // will be 0 in some cases
});
Correct way:
$('matched elements').click(function(){
console.log($('matched elements').index($(this))); // will be the index within set of matched elements
});