473,395 Members | 2,222 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

How Jquery knows that "intIndex" is the loop iteration index?

103 100+
How Jquery knows that "intIndex" is the loop iteration index?

The example, which i do not understand is from: http://www.bennadel.com/blog/534-the-beauty-of-the-jquery-each-method.htm

Expand|Select|Wrap|Line Numbers
  1. // Loop over each hottie.
  2. $( "#girls a.hottie" ).each(
  3.  
  4.     // For each hottie, run this code. The "indIndex" is the
  5.     // loop iteration index on the current element.
  6.     function( intIndex ){
  7.  
  8.         // Bind the onclick event to simply alert the
  9.         // iteration index value.
  10.         $( this ).bind (
  11.             "click",
  12.             function(){
  13.                 alert( "Hottie index: " + intIndex );
  14.             }
  15.             );
  16.  
  17.     }
  18.  
  19.     );
  20.  
Jun 16 '15 #1
3 1393
Dormilich
8,658 Expert Mod 8TB
How Jquery knows that "intIndex" is the loop iteration index?
because it puts the index there.
Expand|Select|Wrap|Line Numbers
  1. // e.g. jQuery 1.11.1 line #383
  2. value = callback.call( obj[ i ], i, obj[ i ] );
Jun 16 '15 #2
gintare
103 100+
THE ANSWER IS IN OFFICIAL DOCUMENTATION:
https://api.jquery.com/index/

The variable in index(variable) function refers to the index of current element.
Jun 16 '15 #3
gintare
103 100+
Thank you Dormilich.
Jun 16 '15 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Danny Anderson | last post by:
Hola, C++ folk! I want to have a do...while loop that works with a different file each iteration, prompting the user for the file name to open and write. The problem I am having is that the...
7
by: Mahesh Kumar Reddy.R | last post by:
Hi Can any body resolve this.. In what cases one of the loop constructs better than other interms of speed , space and any other (redability). thanks mahesh
3
by: Ben R. | last post by:
In an article I was reading (http://www.ftponline.com/vsm/2005_06/magazine/columns/desktopdeveloper/), I read the following: "The ending condition of a VB.NET for loop is evaluated only once,...
1
by: RaH | last post by:
Hello. I am writing a script to parse my logfiles to monitor sshd attempted logins. I know I'm reinventing the wheel, but it's something I want to do. The problem I am having is that upon the...
2
by: Vanecelli | last post by:
The below code is calling a function that populates a certain number of listbox es with options. IT loops as it should if there are only 2 instances of k, but anything greater and the second variable...
7
by: csharpula csharp | last post by:
Hello, I am iterating through objects and have the following case: foreach (classA objectA in classAList) { if (classA.count0) { //now I need to get out of the foreach loop if ...
2
by: irislarin | last post by:
I was wondering if i could ask for some advise. I wrote a script for my workplace that imports CSV data from a template sheet (with data) to a DB table. I wrote it with a series of loops so that I...
0
by: astewes | last post by:
My bxSlider horizontally spans 100% of the browser width - multiple (image) slides display across the viewport, with "moveSlides: 1" set in the options. A total of 8 slides are being rotated. As I...
1
by: gintare | last post by:
Bellow is the example from: http://james.padolsey.com/javascript/closures-in-javascript/ for (var i = 0; i < 100; ++i) { myElements.onclick = ( function(n) { return function() { ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.