Use jQuery to operate on the object array implementation code _ jquery

Source: Internet
Author: User
Use jQuery to operate the implementation code of the object array. For more information, see. JQuery provides the following tools for array element operations:
(1) Examples of arrays and objects: jQuery. each (obj, callback)
The general example method can be used for example object and array. 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.
(2) filter array elements: jQuery. grep (array, callback, [invert])
Filter Array elements using the filter function. This function must pass at least two parameters: the array to be filtered and the filter function. The filter function must return true to retain the element or false to delete the element.
(3) Search for array elements: jQuery. inArray (value, array)
Determine the position of the first parameter in the array (-1 is returned if no value is found ).
(4) Delete duplicate elements: jQuery. unique (array)
Delete repeated elements in the array.
The following instances filter through the object array to obtain or delete the array elements with the specified attribute as the specified value.

The Code is as follows:


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.