From b1d6fa5af593a124635fa79169858a5c223f65a1 Mon Sep 17 00:00:00 2001 From: Arthur Verschaeve Date: Mon, 8 Dec 2014 20:14:24 +0100 Subject: [PATCH] Add note on bug with `.index()` before 1.9 --- page/using-jquery-core/understanding-index.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/page/using-jquery-core/understanding-index.md b/page/using-jquery-core/understanding-index.md index b4e34a32..beafeb36 100644 --- a/page/using-jquery-core/understanding-index.md +++ b/page/using-jquery-core/understanding-index.md @@ -38,7 +38,8 @@ console.log( "Index: " + div.first().index() ); // 0 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. -When `.index()` is called on a jQuery object that contains more than one element, it calculates the index of the first element. + +__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. ## `.index()` with a String Argument