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

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • gintare
    New Member
    • Mar 2007
    • 103

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

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

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

    Code:
    // Loop over each hottie.
    $( "#girls a.hottie" ).each(
     
        // For each hottie, run this code. The "indIndex" is the
        // loop iteration index on the current element.
        function( intIndex ){
     
            // Bind the onclick event to simply alert the
            // iteration index value.
            $( this ).bind (
                "click",
                function(){
                    alert( "Hottie index: " + intIndex );
                }
                );
     
        }
     
        );
  • Dormilich
    Recognized Expert Expert
    • Aug 2008
    • 8694

    #2
    How Jquery knows that "intIndex" is the loop iteration index?
    because it puts the index there.
    Code:
    // e.g. jQuery 1.11.1 line #383
    value = callback.call( obj[ i ], i, obj[ i ] );

    Comment

    • gintare
      New Member
      • Mar 2007
      • 103

      #3
      THE ANSWER IS IN OFFICIAL DOCUMENTATION:


      The variable in index(variable) function refers to the index of current element.

      Comment

      • gintare
        New Member
        • Mar 2007
        • 103

        #4
        Thank you Dormilich.

        Comment

        Working...