The {} in JS represents an object. [] represents an array.
$.each ()
Each handles an array or JSON object.
1 var arr1 = ["AAA", "BBB", "CCC" ]; 2 function (i,val) { 3 alert (i); 4 alert (val); 5 });
View Code
Production Menu:
1<?PHP2 /**3 * Created by Phpstorm.4 * User:administrator5 * date:14-5-276 * Time: Morning 10:197 */8Header ("Content-type:text/html;charset=utf-8");9?>Ten<script src= "Http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js" type= "Text/javascript" ></ Script> One<script> A //Understanding JSON Objects - vararr=[1,3,4,5,6,7, "7"];//equivalent to Arr=array (1,3,4,5,6,7, "7"); -document.write (arr[2]); the - varss={' name ': "Xiaoming", ' age ': 18}; -document.write ("My name is" +ss[' name ']+ "i" +ss.age+ "<br/>"); - + varmy=function(){ - return"123456"; + }; Adocument.write (My () + "<br/>"); at varperson={ -Namefunction(){return"Abama"}, -Agefunction(){return"52"} - }; -document.write (Person.name () +person.age ()); - in //Menus is a menu that contains multiple modules. How to read out and display it - var_menus={' Meuns ':[ to { +' Meunid ': 1, ' meunname ': "System Management", -' Meuns ': [{' Name ': ' Add user ', ' icon ': ', ' url ': ' http://www.baidu.com '}, the{' name ': ' Delete user ', ' icon ': ', ' url ': '}, *{' Name ': ' Modify permission ', ' icon ': ', ' url ': '}, ${' name ': ' System log ', ' icon ': ', ' url ': '}Panax Notoginseng ]}, - { the' Meunid ': 2, ' meunname ': "Financial Management", +' Meuns ': [{' name ': ' Financial payment ', ' icon ': ', ' url ': ' http://www.baidu.com '}, A{' name ': ' Financial Review ', ' Icon ': ', ' url ': '}, the{' name ': ' View ', ' icon ': ', ' url ': '}, +{' name ': ' No ', ' icon ': ', ' url ': '} - ]} $ ]}; $document.write (_menus.meuns[1].menus[0].name); - -</script> the -<script>Wuyi functionset_meuns () { the$ (' #meuns '). empty (); - varList= ""; Wu$.each (_menus.meuns,function(i,k) { -list+= "<div title=" + k.meunname+ "><ul>" About$.each (K.meuns,function(i,k) { $list+= "<li><a href=" + k.url+ ">" + k.name+ "</a></li>"; - }); -list+= "</ul></div>"; - }); A + the alert (list); -$ (' #meuns '). append (list); $ } the$ (document). Ready (function(){ the set_meuns (); the }) the</script> - in the<body> the<div id= "Meuns" style= "border:1 solid red;width:300px;" > About Menu List Location the</div> the the</body> +View Code