<Html>
<Head>
<Script src = "jquery-1.3.2.min.js"> </script>
</Head>
<Body>
<Input type = "text" id = "2"/>
<Input type = "text" id = "3"/>
<Input type = "text" id = "4"/>
<Input type = "text" id = "5"/>
<Input type = "text" id = "6"/>
<Input type = "text" id = "7"/>
<Script>
Var input1 = $ ("input"). eq (0); // retrieve the first input
Var id1 = input1.attr ("id"); // retrieve the id of the first input
Alert (id1)
Var input2 = $ ("input"). eq (1); // retrieves the second input
Var id2 = input2.attr ("id"); // retrieves the id of the second input.
Alert (id2)
Var input3 = $ ("input"). eq (2); // retrieves the third input
Var id3 = input3.attr ("id"); // retrieves the third input
Alert (id3)
// Jquery Retrieves all the input of the page and then loops through all the input
Var inputArray = $ ("input") // obtain all input values and put them in an array.
InputArray. each (// use the array's cyclic function to loop through this input Array
Function (){
Var input = $ (this); // every input element in the loop
Alert (input. attr ("id") // view the id of each input in the loop
}
)
// You can also use the following for loop to loop the input array.
For (var I = 0; I <inputArray. length; I ++) {// loop the entire input Array
Var input = inputArray [I]; // obtain each input
Alert (input. id );
}
</Script>
</Body>
</Html>
Author wbandzlhgod