Skip to content

article on index() - index() with no arg now implicitly calls first() not last from jQuery 1.91 #276

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
trystanclarke opened this issue Feb 28, 2013 · 2 comments

Comments

@trystanclarke
Copy link

Hi, I just noticed this while trying out the code snippets on jsFiddle - it seems that .index() returns the index of the first item not the last item as of jQuery 1.91. If you run the snippet using 1.83 it uses the last one.

This is on the page at http://learn.jquery.com/using-jquery-core/understanding-index/

@dmethvin
Copy link
Member

dmethvin commented Mar 1, 2013

The docs are wrong here. Before this fix the method didn't return consistent results, now it does. we just need to remove that note and add one that before 1.9 you should ensure that the .index() method is only passed one element or the results may be incorrect.

@arthurvr
Copy link
Member

arthurvr commented Dec 8, 2014

However 54946db fixed the examples, adding a note on the bug might still be welcome. If you don't know about the issue, the examples are now even more confusing. I'il open a PR this afternoon.

@gnarf gnarf closed this as completed in 9ec218b Dec 23, 2014
arthurvr added a commit to arthurvr/learn.jquery.com that referenced this issue Jan 4, 2015
Talk about why we use `.first()` in the examples.

Closes jquerygh-582
Fixes jquerygh-276
Krinkle pushed a commit that referenced this issue Apr 9, 2024
Talk about why we use `.first()` in the examples.

Closes gh-582
Fixes gh-276
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging a pull request may close this issue.

3 participants