Introduction to each use of global functions in jquery

Source: Internet
Author: User
Tags json

jquery contains two each one is $ (). Each another is the $.each difference lies in the previous one is the built-in function of the jquery object and then this is the traversal function of the object.

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 letter The index of each weight in the number 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 Property by using a key as an index import read out the corresponding value through a similar get accessor to return, hoping to give a friend with doubts to answer.

Related Article

E-Commerce Solutions

Leverage the same tools powering the Alibaba Ecosystem

Learn more >

Apsara Conference 2019

The Rise of Data Intelligence, September 25th - 27th, Hangzhou, China

Learn more >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

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.