Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8532697
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T09:46:28+00:00 2026-06-11T09:46:28+00:00

Looking at the docs for the .each() function in jquery shows the following method

  • 0

Looking at the docs for the .each() function in jquery shows the following method signature:

.each( function(index, Element) )

http://api.jquery.com/each/

I can understand needing to pass in an index so that it is available for use within the callback but why would you explicitly include the Element parameter if you can just reference the current element by the this keyword? Is it there just so that you can specify an instance name of your choice? I mean, if you still have to wrap a named instance in the jquery method $() to get back a jquery object isn’t that exactly the same as this? The docs don’t seem to mention why it is there.

Update:

I think this has something to do with closures but I’m not sure. It seems like what I’m referring to as a “named instance” is actually a local copy or clone of the element in the array stored in a variable within the scope of the callback. I suspect that by using this it is referencing a variable as if it were some sort of closure. @thecodeparadox found something in a firebug console that got me thinking about this. Still not quite sure what the difference is though or why you would ever need to have a locally scoped value of the element in the array.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T09:46:29+00:00Added an answer on June 11, 2026 at 9:46 am

    the context of “this” can change often inside a .each block so they provide a reference to the element saving you from having to do something like “var that = this;”

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've been looking at examples of REST API's like Netflix http://developer.netflix.com/docs/REST_API_Reference#0_59705 and Twitter and
I'm looking at the Plugin Authoring article at http://docs.jquery.com/Plugins/Authoring and saw this example in
I'm looking the documentation about publishing the message to wall from Facebook app http://developers.facebook.com/docs/reference/dialogs/feed/
I am looking into authenticating via google. I dont understand how it works: http://code.google.com/apis/accounts/docs/OpenID.html#Samples
I'm currently looking at the the documentation for Django sites: http://docs.djangoproject.com/en/dev/ref/contrib/sites/#ref-contrib-sites which explains how
I am looking into docs.phonegap.com and found no function that would open up video
I am looking at jquerymobile split lists... http://jquerymobile.com/demos/1.0a4.1/docs/lists/lists-split.html Currently, it has: Main middle part,
I'm looking for a workaround to this Published Twitter API bug: http://code.google.com/p/twitter-api/issues/detail?id=214 When you
I successfully deployed a Script as a webapp: https://docs.google.com/macros/s/AKfycbxJvSRpH7dMmrmMnkJW6LRZwMImqQ_5MT8tWMYUVXryWlgw1Fck/exec And looking in the docs,
i was looking everywhere to find a good guide,or docs about the youtube api

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.