如何循环遍历json数据到table

2021-01-24 14:15

阅读:541

标签: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>Documenttitle>
 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 = $(
);
28         $.each(item,function(name,val){
29             var $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


评论


亲,登录后才可以留言!