JS Loop traversal JSON data classification: JS technology js JQuery 2010-12-01 13:56 43646 people read reviews (5) Favorite report Jsonc JSON data such as: {"options":&quo T [{

Source: Internet
Author: User

JS looping through JSON dataCategory: JS technology js JQuery2010-12-01 13:5643646 People readComments (5) CollectionReportJsonc

JSON data such as: {"Options": "[{/" text/":/" Wang Jia Wan/",/" value/":/" 9/"},{/" text/":/" Li Jia Wan/",/" Valu
e/":/" 10/"},{/" text/":/" Shao Jia Bay/",/" value/":/" 13/"}]"}

Use JS to write:

[JavaScript]View Plaincopyprint?
  1. varData=[{name:"a", Age:12},{name:"B", Age:11},{name:"C", Age:13},{name:"D", age:14}];
  2.        for var  O  in  data) {  
  3. Alert (o);
  4. Alert (Data[o]);
  5.         alert (" text: " +data[o].name+ "  value: " +data[o].age );   
  6. }

Or

[JavaScript]View Plaincopyprint?
  1. <script type= " Text/javascript " >&NBSP;&NBSP;
  2. function text () {
  3. varjson = {"Options":"[{/"text/":/"Wang Jia Wan/",/"value/":/"9/"},{/"text/":/"Li Jia Wan/",/"value/":/"10/"},{/"text/":/"Shao Jia Bay/",/"value/":/"13/"}]"}   
  4. JSON = eval (json.options)
  5.   for var  i=0; i< json.length; i++)   
  6. &NBSP;&NBSP;{&NBSP;&NBSP;
  7.      alert (Json[i].text+"   "  + json[i].value)   
  8. }
  9. }
  10. </script>

JS Loop traversal JSON data classification: JS technology js JQuery 2010-12-01 13:56 43646 people read reviews (5) Favorite report Jsonc JSON data such as: {&quot;options&quot;:&quo T [{

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.