Why does the .index() function not work?
Example: http://jsfiddle.net/peeter/ePMFe/
It returns the index as -1, instea开发者_如何学编程d of the actual index. Any ideas are greatly appreciated.
because your jQuery array is the UL and you're searching for an LI.
console.log($("#myul li").index(tab));
should work fine
index start with 0 and u want to search the index of tab_3 then it will b 2
see the update
While this doesn't answer your actual question, you can solve the problem by using $(tab).index()
.
精彩评论