json数组到bigroad表

时间:2016-10-03 18:10:58

标签: javascript jquery html

我需要帮助根据Bigroad记分板格式的上一个和上一个结果使用JSON数组填充我的表。

[{"result":"M","no":"1"},{"result":"M","no":"2"},{"result":"M","no":"3"},{"result":"D","no":"4"},{"result":"M","no":"5"},{"result":"M","no":"6"},{"result":"M","no":"7"},{"result":"W","no":"8"},{"result":"W","no":"9"},{"result":"M","no":"10"},{"result":"D","no":"11"},{"result":"M","no":"12"},{"result":"W","no":"13"},{"result":"M","no":"14"}]

我已经尝试过无数次,无济于事我一直坚持与json数组的last和previous对象进行比较。

我用这个来填充另一个表我试过类似于这个

的方法
function history() {

$.getJSON('/history.php', function(data) {

    $.historyText = '';

    $.each(data, function(i) {

        $.winner = data[i].result;
        $.no = data[i].no;
        $.historyText = '<div class="history ' + $.winner + '" >' + $.no + '</div>';
        $(".cols-" + i).html($.historyText);

    });

});

}

我需要它像这样输出。 任何建议都会大大贬低。

&#13;
&#13;
table  {border-collapse:collapse;border-spacing:0;}
table td{font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;}
&#13;
<table>
  <tr>
    <td class="cols-0">1m</td>
    <td class="cols-5">8w</td>
    <td class="cols-10">10m</td>
    <td class="cols-15">13w</td>
    <td class="cols-20">14m</td>
    <td class="cols-25"></td>
    <td class="cols-30"></td>
    <td class="cols-35"></td>
    <td class="cols-40"></td>
    <td class="cols-45"></td>
  </tr>
  <tr>
    <td class="cols-1">2m</td>
    <td class="cols-6">9w</td>
    <td class="cols-11">11d</td>
    <td class="cols-16"></td>
    <td class="cols-21"></td>
    <td class="cols-26"></td>
    <td class="cols-31"></td>
    <td class="cols-36"></td>
    <td class="cols-41"></td>
    <td class="cols-46"></td>
  </tr>
  <tr>
    <td class="cols-2">3m</td>
    <td class="cols-7"></td>
    <td class="cols-12">12m</td>
    <td class="cols-17"></td>
    <td class="cols-22"></td>
    <td class="cols-27"></td>
    <td class="cols-32"></td>
    <td class="cols-37"></td>
    <td class="cols-42"></td>
    <td class="cols-47"></td>
  </tr>
  <tr>
    <td class="cols-3">4d</td>
    <td class="cols-8"></td>
    <td class="cols-13"></td>
    <td class="cols-18"></td>
    <td class="cols-23"></td>
    <td class="cols-28"></td>
    <td class="cols-33"></td>
    <td class="cols-38"></td>
    <td class="cols-43"></td>
    <td class="cols-48"></td>
  </tr>
  <tr>
    <td class="cols-4">5m</td>
    <td class="cols-9">6m</td>
    <td class="cols-14">7m</td>
    <td class="cols-19"></td>
    <td class="cols-24"></td>
    <td class="cols-29"></td>
    <td class="cols-34"></td>
    <td class="cols-39"></td>
    <td class="cols-44"></td>
    <td class="cols-49"></td>
  </tr>
</table>
&#13;
&#13;
&#13;

0 个答案:

没有答案