$.each (obj, fn) __javascript

Source: Internet
Author: User
$.each (obj, FN)
Each (function (I,item) {})

A general iterative function that can be used to approximate an object and array.

This function differs from $ (). each (), which is a function designed to iterate and execute the jquery object. This function can be used to iterate over any object and array. The callback for this function contains two parameters: the first is a key (object) or index (array), and the second is a value.

return value: Object

Parameters:
Obj (object): objects or arrays to repeat iterations
fn (function): functions to be executed in each object

Example:

This is an example of all the items in an iterative group, where each item and index is accessed through a function.

$.each ([0,1,2], function (i, N) {alert ("Item #" + i + ":" + N);});
Example:

This is an example of all the attributes in an iterative object that accesses the name and value of each property through a function.

$.each ({name: "John", Lang: "JS"}, function (i, N) {alert ("Name: + i +", Value: "+ n";});

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.