About global functions in jquery Introduction to each use _jquery

Source: Internet
Author: User

jquery contains two each one is $ (). Each another is $.each the difference lies in the previous one is the built-in function of the jquery object and this is the traversal function of the object generally used in Ajax to get different object data to traverse to JSON for example jquery The Getjson shortcut method can conveniently obtain the JSON file in the specified URL jquery will be built into the call JS native eval function to parse JSON text into a JS object and then traverse through each global function to get the value syntax each (data, [Params],function (current item index, current item)) This is also a great difference from each of the built-in functions, and the index in the built-in function is an identifier used to indicate where to begin the traversal, followed by the element element that specifies how many elements to traverse and the global The index of each weight in the function refers to the key in each key value pair in JSON, which is key! In the jquery Basics tutorial, the author writes the appropriate code but fails to take the parameter to the correct sample code as follows

$.each (Data,function (entryindex,entry) {var html = entry[' term '}); The friend who has read this book must be very puzzled about entryindex in the end is what? In fact, Entryindex is the ' term ' but the author did not use the index to enter the key value directly from the JSON, through debugging to find the following problems generally translated into the index, personal opinion or should be the key to address the entry is a key value pairs of the property value is a field when this A property can be returned by using a key as an index to read the corresponding value through a similar get accessor, hoping to answer a friend who has doubts.

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.