Jquery contains two each values: $ (). the other value of each is $. the difference between each is that the first is the built-in function of the jquery object, and the other is the object's traversal function. jquery contains two each values: $ (). the other value of each is $. the difference between each is that the first is the built-in function of the jquery object, and the other is the object's traversal function. It is generally used to obtain different object data in ajax for traversal. Taking json as an example, jquery's getJSON Shortcut method can be convenient. get the json file in the specified url. jquery will call the js native eval function internally to parse the json text and convert it into a js object. Then, it will traverse it through the each global function to get the Value Syntax each (data, [params], function (current item index, current item), which is also very different from the built-in function each, the index in the built-in function is an identifier used to indicate where the traversal starts. The element specifies the number of elements to be traversed. The each index in the global function refers to the KEY in each KEY-Value Pair in json, that is, the KEY! In the Basic jquery tutorial, the author wrote the corresponding code for example, but could not correctly sample the parameters. The sample code is as follows:
$. Each (data, function (entryIndex, entry) {var html = entry ['condition']}); friends who have read this book may wonder what entryIndex is? In fact, entryIndex is a 'termin', but the author directly fills in the key value from json instead of using the index. After debugging, it is found that the following problems are commonly translated as indexes, in my opinion, the entry should still be called as a key. It is an attribute value that contains a key-value pair. When this attribute is imported using a key as an index, the corresponding value is read through a get accesser similar method, I hope I can answer questions from any of my friends.