Jquery-traverses the array returned by the background

Source: Internet
Author: User

$. Each (array, [callback]) Traversal
Unlike the $. Each () method of the jquery object, this method can be used to sample all objects (not just arrays ~). The callback function has two parameters: the first is the object's member or array index, and the second is the corresponding variable or content. if you want to exit the each loop, the callback function returns false. Other return values are ignored.
Each traversal is a variant of the For Loop in normal event processing, but it is more powerful than the for loop. in the array, it can easily obtain the array index and the corresponding value. example:

The usage is as follows:

2013-06-03 13:16:51, 768 action. tasksplitaction Debug: Print 0th:
[{ID: 1, PID: 0, name: "Design Institute", open: true}, {ID: 2, PID: 1, name: "Task 2", open: true}, {ID: 3, PID: 2, name: "bjgs56", open: true}, {ID: 4, PID: 3, name: "rnc5651 (r307) ", open: true}, {ID: 5, PID: 4, name:" Fengtai South Carolina airport ztdb2 ", open: true}, {ID: 6, PID: 1, Name: "Task 3", open: true}, {ID: 7, PID: 6, name: "bjgs56", open: true}, {ID: 8, PID: 7, name: "r5631", open: true}, {ID: 9, PID: 8, name: "M", open: true}, {ID: 10, PID: 8, name: "Beijing xinfa nightclub m", open: true}, {ID: 11, PID: 8, name: "hongtu Teng business dcs2", open: true}, {ID: 12, PID: 8, name: "hongtu Teng commerce dcs1", open: true}, {ID: 13, PID: 8, Name: "Fengtai zhangyi village No. 125 courtyard dcs3", open: true}, {ID: 14, PID: 1, name: "Task 1", open: true}, {ID: 15, PID: 14, name: "bjgs56", open: true}, {ID: 16, PID: 15, name: "r5635", open: true}, {ID: 17, PID: 16, name: "ideal city stage 3 m3", open: true}, {ID: 18, PID: 16, name: "ideal city stage 3 m2 ", open: true}]
2013-06-03 13:16:51, 768 action. tasksplitaction Debug: Print 1st:
[{ID: 19, PID: 0, name: "Xi'an huicheng", open: true}, {ID: 20, PID: 19, name: "Task 2", open: true}, {ID: 21, PID: 20, name: "bjgs56", open: true}, {ID: 22, PID: 21, name: "rnc5651 (r307) ", open: true}, {ID: 23, PID: 22, name:" Daxing shuimen hospital ztd3 ", open: true}, {ID: 24, PID: 22, name: "Shijingshan Pressure Vessel ztd1", open: true}, {ID: 25, PID: 22, name: "Shijingshan Pressure Vessel ztd2", open: true}, {ID: 26, PID: 22, name: "Shijingshan Pressure Vessel ztd3", open: true}, {ID: 27, PID: 22, name: "Fengtai South Pacific Airport ztdb1", open: true },{ ID: 28, PID: 19, name: "Task 3", open: True },{ ID: 29, PID: 28, name: "bjgs56 ", open: true}, {ID: 30, PID: 29, name: "r5631", open: true}, {ID: 31, PID: 30, Name: "hongtuteng business dcs3", open: true}, {ID: 32, PID: 19, name: "Task 1", open: true}, {ID: 33, PID: 32, name: "bjgs56", open: true}, {ID: 34, PID: 33, name: "r5635", open: true}, {ID: 35, PID: 34, name: "ideal city phase III M1", open: true}]
2013-06-03 13:16:51, 768 action. tasksplitaction Debug: Print 2nd:
[{ID: 36, PID: 0, name: "Huaxing", open: true}, {ID: 37, PID: 36, name: "Task 2", open: true}, {ID: 38, PID: 37, name: "bjgs56", open: true}, {ID: 39, PID: 38, name: "rnc5651 (r307) ", open: true}, {ID: 40, PID: 39, name:" Shi jingshan Yongle Middle School ztd1 ", open: true}, {ID: 41, PID: 36, name: "Task 3", open: true}, {ID: 42, PID: 41, name: "bjgs56", open: true}, {ID: 43, PID: 42, name: "r5631", open: true}, {ID: 44, PID: 43, name: "dcs2, No. 125, zhangyi village, Fengtai", open: true }, {ID: 45, PID: 43, name: "dcs1, open: true}, {ID: 46, PID: 36, Name: "Task 1", open: true}, {ID: 47, PID: 46, name: "bjgs56", open: true}, {ID: 48, PID: 47, name: "r5635", open: true}, {ID: 49, PID: 48, name: "ideal city stage III M4", open: true}, {ID: 50, PID: 48, name: "dcs3", open: true}, {ID: 51, PID: 48, name: "dcs2", open: true}]

<Body> 


URL: http://www.nowamagic.net/jquery/jquery_UseArray.php

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.