// Determine the position of an element
// The matched set of elements
160 index: function (elem ){
// Locate the position of the desired element
Return jQuery. inArray (
// If it takes es a jQuery object, the first element is used
Elem & elem. jquery? Elem [0]: elem
, This );
},
The index function of row 160 is used to return the subscript of an element in the query result. The subscript starts from 0. If no matching element is found,-1 is returned.
Note: The inArray function is defined in row 1086.
1086 inArray: function (elem, array ){
1087 for (var I = 0, length = array. length; I <length; I ++)
1088 // Use === because on IE, window = document
1089 if (array [I] === elem)
1090 return I;
1091
1092 return-1;
1093 },
This is a very simple function. check whether a specific element exists in the array. Pay attention to the 1,089th rows and use = to determine whether it is the same object.
Source: blog