Home >Web Front-end >JS Tutorial >Methods for operating arrays based on jQuery_jquery
jQuery provides two functions:
1.$.map(array,callback(element,index));
For each element in the array, call the callback() function, and finally return a new array, the original array remains unchanged
For example:
What comes back is a new array
return value * 2;
})
2. $.each(array,fn);
Mainly used to traverse arrays without modifying the array. It can be traversed for ordinary arrays or "key-value arrays".
This can be used directly in each function to represent the value of the current element.
For example: Get the selected item in the checkbox
$(function () {
var arr = [];
arr[key] = value.text();
var lengtha = $('input[type=checkbox][checked=checked]').length; 🎜>
})