<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>动态拼接文本框</title> </head> <body> <div > <table id="table_id"> </table> </div> <script type="text/javascript" src="js/jquery.js" ></script> <script type="text/javascript"> //使用$.post()/$.getJson/$.ajax 获取接口读取数据 var strHtml=""; $.post("url",{参数1:值,参数2:值2..... },function(d){ //循环主体部分,必须吧头和为单独弄出来才行 <tr> //th 这部分不需要循环一定要写死 <th>用户编号</th> <th>用户姓名</th> <th>用户年龄</th> <th>用户工号</th> </tr> //需要循环的部分 data json传过来的数据 $(d["data"]).each(function(i,k){ strHtml+="<tr>"'+k.id +'""</tr>"; strHtml+="<tr>"'+k.name +'""</tr>"; strHtml+="<tr>"'+k.age +'""</tr>"; strHtml+="<tr>"'+k.SN+'""</tr>"; }) }); $("#table_id").append(strHtml); </script> </body> </html>
jquery 动态拼接table
猜你喜欢
转载自blog.csdn.net/weixin_41600552/article/details/80085804
今日推荐
周排行