web窗体中如何添加table

<tableclass="layui-table" lay-skin="line"id="datas">

  <colgroup>

    <col width="150">

    <col width="200">

    <col>

  </colgroup>

  <thead>

  <tr>

    <th>昵称</th>

    <th>加入时间</th>

    <th>签名</th>

  </tr>

  </thead>

  <tbody>

  <tr id="template">

    <td id="id"></td>

    <td id="url"></td>

    <td id="title"></td>

  </tr>

  </tbody>

</table>

js代码

<script>

  var data = [{

      "id": 1,

      "url":"http://www.jqcool.net",

      "switch": 1,

      "order": 1,

      "pid": 0,

      "title": "Online Programknowledge share and study platform"

    },

      {

        "id": 2,

        "url":"http://www.baidu.com",

        "switch": 0,

        "order": 2,

        "pid": 2,

        "title": "这是测试的数数据这是测试的数数据"

      },

      {

        "id": 3,

        "url":"http://www.taobao.com",

        "switch": 0,

        "order": 3,

        "pid": 2,

        "title": "淘宝购物"

      },

      {

        "id": 4,

        "url":"http://www.jqcool.net1",

        "switch": 1,

        "order": 4,

        "pid": 2,

        "title": "Online Programknowledge share and study platform2"

      },

      {

        "id": 5,

        "url":"http://www.baidu.com1",

        "switch": 0,

        "order": 5,

        "pid": 2,

        "title": "这是测试的数数据2"

      },

      {

        "id": 6,

        "url":"http://www.taobao.com1",

        "switch": 1,

        "order": 6,

        "pid": 0,

        "title": "淘宝购物2"

      }];

  $.each(data, function (i, n) {

    var row = $("#template").clone();

    row.find("#id").text(n.id);

    row.find("#url").text(n.url);

    row.find("#title").text(n.title);

    row.appendTo("#datas");//添加到模板的容器中

  });

</script>

效果


站位
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 4
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值