欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

jQuery實(shí)現(xiàn)動(dòng)態(tài)給table賦值的方法示例

 更新時(shí)間:2017年07月04日 10:55:18   作者:小魏的馬仔  
這篇文章主要介紹了jQuery實(shí)現(xiàn)動(dòng)態(tài)給table賦值的方法,結(jié)合具體實(shí)例形式分析了jQuery動(dòng)態(tài)操作table表格節(jié)點(diǎn)的相關(guān)技巧,需要的朋友可以參考下

本文實(shí)例講述了jQuery實(shí)現(xiàn)動(dòng)態(tài)給table賦值的方法。分享給大家供大家參考,具體如下:

html

請(qǐng)忽視各種class,因?yàn)榍岸擞玫氖莑ayui

<table class="layui-table" lay-skin="line" id="datas">
  <colgroup>
    <col width="150">
    <col width="200">
    <col>
  </colgroup>
  <thead>
  <tr>
    <th>昵稱</th>
    <th>加入時(shí)間</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 Program knowledge share and study platform"
    },
      {
        "id": 2,
        "url": "http://www.baidu.com",
        "switch": 0,
        "order": 2,
        "pid": 2,
        "title": "這是測(cè)試的數(shù)數(shù)據(jù)這是測(cè)試的數(shù)數(shù)據(jù)"
      },
      {
        "id": 3,
        "url": "http://www.taobao.com",
        "switch": 0,
        "order": 3,
        "pid": 2,
        "title": "淘寶購(gòu)物"
      },
      {
        "id": 4,
        "url": "http://www.jqcool.net1",
        "switch": 1,
        "order": 4,
        "pid": 2,
        "title": "Online Program knowledge share and study platform2"
      },
      {
        "id": 5,
        "url": "http://www.baidu.com1",
        "switch": 0,
        "order": 5,
        "pid": 2,
        "title": "這是測(cè)試的數(shù)數(shù)據(jù)2"
      },
      {
        "id": 6,
        "url": "http://www.taobao.com1",
        "switch": 1,
        "order": 6,
        "pid": 0,
        "title": "淘寶購(gòu)物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>

效果

更多關(guān)于jQuery相關(guān)內(nèi)容感興趣的讀者可查看本站專題:《jQuery表格(table)操作技巧匯總》、《jQuery操作json數(shù)據(jù)技巧匯總》、《jQuery form操作技巧匯總》、《jQuery常用插件及用法總結(jié)》、《jQuery擴(kuò)展技巧總結(jié)》及《jquery選擇器用法總結(jié)

希望本文所述對(duì)大家jQuery程序設(shè)計(jì)有所幫助。

相關(guān)文章

最新評(píng)論