• 把数据获取到页面上 只显示双数 先for循环 把每个数组里面的值分别取出来 在显示在页面上


    <!DOCTYPE html>
    <html lang="en">
    <head>
    <meta charset="UTF-8">
    <title></title>
    <script src="jquery-3.2.0.min.js"></script>
    </head>
    <body>
    <table id="tab" border="1">
    <tr></tr>
    </table>

    <script>
    var data = [{hehe:"1",layer:"呵呵3",hehe1:"weqwe322qeqe"},
    {hehe:"2",layer:"呵呵3",hehe1:"weqweqee33qe"},
    {hehe:"3",layer:"呵呵242343",hehe1:"weqweqee33qe"},
    {hehe:"4",layer:"呵呵3234",hehe1:"weqweqee33qe"},
    {hehe:"5",layer:"呵呵323",hehe1:"weqweqee33qe"},
    {hehe:"6",layer:"呵呵323",hehe1:"weqweqee33qe"},
    {hehe:"7",layer:"呵呵323",hehe1:"weqweqee33qe"},
    {hehe:"8",layer:"呵呵323",hehe1:"weqweqee33qe"},
    {hehe:"9",layer:"呵呵312323",hehe1:"weqweqee33qe"},
    {hehe:"10",layer:"呵呵312323",hehe1:"weqweqee33qe"},
    {hehe:"11",layer:"呵呵312323",hehe1:"weqweqee33qe"},
    {hehe:"12",layer:"呵呵312323",hehe1:"weqweqee33qe"},
    {hehe:"13",layer:"呵呵323",hehe1:"weqweqee33qe"},
    {hehe:"14",layer:"呵呵321323",hehe1:"weqweqee33qe"},
    {hehe:"15",layer:"呵呵4",hehe1:"weqweqedsqe"}];

    $(function() {
    for (var i = 0; i < data.length; i++) {
    if(i%2==1){
    var sb = '<tr>' +
    '<td>' +(i+1)+ '</td>' +
    '<td>' + data[i].hehe + '</td>' +
    '<td>' + data[i].layer + '</td>' +
    '<td>' + data[i].hehe1 + '</td>' +
    '</tr>';

    $('#tab').append(sb);
    }
    }
    });
    </script>
    </body>
    </html>
  • 相关阅读:
    第四次作业
    第三次作业
    作业,11
    作业,10
    作业,9
    作业,8
    作业,7
    作业,6
    作业,5
    作业,4
  • 原文地址:https://www.cnblogs.com/zyhh/p/7009469.html
Copyright © 2020-2023  润新知