HTML:
Div 1
Div 2
Div 3
<
You have to make it relative to what you're testing against. Use:
$(".test").each(function(){
var i = $('.test').index($(this));
console.log(i);
});
jsFiddle example
Per the docs on .index():
If .index() is called on a collection of elements and a DOM element or jQuery object is passed in, .index() returns an integer indicating the position of the passed element relative to the original collection.