Skip to content

Commit 9ec218b

Browse files
arthurvrgnarf
authored andcommitted
Understanding Index: Add note on <1.9 bug
Talk about why we use `.first()` in the examples. Closes jquerygh-582 Fixes jquerygh-276
1 parent 59e5105 commit 9ec218b

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

page/using-jquery-core/understanding-index.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@ console.log( "Index: " + div.first().index() ); // 0
3838

3939
In the first example, `.index()` gives the zero-based index of `#foo1` within its parent. Since `#foo1` is the second child of its parent, `index()` returns 1.
4040

41-
When `.index()` is called on a jQuery object that contains more than one element, it calculates the index of the first element.
41+
42+
__Note__: Before jQuery 1.9, `.index()` only worked reliably on a single element, which is why we've used `.first()` on each of our examples. In jQuery 1.9+ this can be ignored, as the API was updated to define that it operates on the first element only.
4243

4344
## `.index()` with a String Argument
4445

0 commit comments

Comments
 (0)