You have selectors:
Example: http://jsfiddle.net/RaV35/
// element---v collection----------v alert($("input[value='0']").index(":checkbox")); alert($("input[value='1']").index(":checkbox"));
When passing the selector index() [docs] method, a separate element for which you want the index to be the element against which .index() called.
The selector you pass to .index() represents the collection with which the element in the jQuery source object is checked.
When the source jQuery object (on the left) also contains a collection, only the first is checked for its index against the selector on the right. That is why it worked with value="0" .
// v--- only the first is tested (and it has value="0")... $(':checkbox').index("input[value='0']") // ----------------------^ ...and it is at index 0 of this "collection"
source share