Background: The code applied to the essay comes from the previous essay, mvc&jquery How to dynamically generate a table from a list, and some of the code is no longer duplicated.
The code is as follows:
1$("#btnTan"). Click (function () {2 vararray=[];3 varTMP = $ ("#destTable TR");4 for(vari =0; i < tmp.length; i++) {5Array[i] = Tmp.eq (i). Find (". Age"). text ();6 }7 var out= Array.join (';');8Alert out);9 if($.inarray ("", Array) >=0) {TenAlert'A 18-year-old classmate.'); One } AArray.Length =0; - alert (Array); -});
- Array declaration: Var array=[];
- var tmp = $ ("#destTable tr") is itself an array that gets all the TR elements in the DestTable
- Gets the element I in the array and assigns a value to the target array: array[i] = Tmp.eq (i). Find (". Age"). text ();
- Inserts a semicolon between the elements of the array: Array.join (';')
- The judgment is contained in the array: $.inarray ("", "array"), if not present, returns-1;
- Empty array: array.length=0;
Really is too sleepy, days long bright, estimated that mosquitoes are also beginning to rest, the following is a reference to the article:
Clears whether the array contains the specified element
Went to bed.
How to manipulate arrays in JS