码迷,mamicode.com
首页 > Web开发 > 详细

如何循环遍历json数据到table

时间:2020-07-06 11:03:01      阅读:109      评论:0      收藏:0      [点我收藏+]

标签:app   query   otc   doctype   cdn   javascrip   value   json   asc   

 1 <!DOCTYPE html>
 2 <html lang="en">
 3 <head>
 4     <meta charset="UTF-8">
 5     <title>Document</title>
 6     <script src="http://cdn.bootcss.com/jquery/1.11.2/jquery.js"></script>
 7     <style type="text/css">
 8         
 9     </style>
10 </head>
11 <body>
12     <table id="myTable">
13         <thead>
14             <tr>
15                 <th>代号</th>
16                 <th>城市</th>
17                 <th>附加数字</th>
18             </tr>
19         </thead>
20         <tbody></tbody>
21     </table>
22 </body>
23 </html>
24 <script type="text/javascript">
25     var data = [{name:6101,value:北京市,age:11}, {name:6102,value:天津市,age:11}, {name:6103,value:上海市,age:22}];
26     $.each(data,function(index,item){
27         var $tr = $(<tr>);
28         $.each(item,function(name,val){
29             var $td = $(<td>).html(val);
30             $tr.append($td);
31         });
32         $(#myTable tbody).append($tr);
33     });
34 </script>

 

如何循环遍历json数据到table

标签:app   query   otc   doctype   cdn   javascrip   value   json   asc   

原文地址:https://www.cnblogs.com/dancer0321/p/13253274.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!