The reason you aren't getting the value you expect is probably because you are assuming the index is based on the selector you created to bind the click event to. In fact the index is based on the element and its siblings. From the index page
If no argument is passed to the .index()
method, the return
value is an integer indicating the position of the first element within
the jQuery object relative to its sibling elements.Because you have other divs in between the ones with the class headerClass they are also counted when the index is determined. Are you just determining the index to do something with its children or next sibling div? If that's the case, take a look at some of the methods here:
http://api.jquery.com/category/traversing/If there is something specific you need post it here.
Hope that gets you headed in the right direction
Dave