Two functions are available in jquery:
1.$.map (Array,callback (Element,index));
For each element in the array, call the callback () function, eventually returning a new array, the original array unchanged
For example:
$ (function () {
var arrint = [1, 3, 5, 79];
var B = $.map (Arrint, function (value, key, a) {//map returns a new array
return value * 2;
});
})
2. $.each (ARRAY,FN);
The main use is to traverse the array, not modify the array, for ordinary arrays or "key-value arrays" can be traversed.
You can use this directly in each function to represent the value of the current element.
For example: Gets the selected item in the checkbox
<script type= "Text/javascript" >
$ (function () {
var arr = [];
$ (' input[type=checkbox] '). Click (function () {
$ (' input[type=checbox]:checked '). each (function (key, value) {
Arr[key] = Value.text ();
});
var Lengtha = $ (' input[type=checkbox][checked=checked] '). length; $ (' #spMsg '). Text (' total ' + Lengtha + ' is selected respectively: ' + arr ');
})
})