[] {} and JSON object

Source: Internet
Author: User

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

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.