Home > Web Front-end > JS Tutorial > body text

Methods for operating arrays based on jQuery_jquery

WBOY
Release: 2016-05-16 17:36:43
Original
1029 people have browsed it

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; 🎜>

                                                                                                    

})

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template