代碼以下:javascript
<html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <style> table tbody { display: block; height: 500px; overflow-y: scroll; } table thead, tbody tr { display: table; width: 100%; table-layout: fixed; } table thead { width: calc( 100% - 1em ); background: #e9f5f7; } table { border-width: 1px 1px 1px 1px !important; border: 1px solid #ccc; } table tbody tr td { border-bottom: 1px solid #ccc; border-left: 1px solid #ccc; word-wrap:break-word; } table thead tr th { border-width: 1px 1px 1px 1px !important; border-left: 1px solid #ccc; } .even { background-color: white; } .odd { background-color: #f5f5f5; } </style> </head> <body> <table width="80%" style="table-layout:fixed" id="tableValue" border="0" cellspacing="1" cellpadding="0"> <thead> <tr> <th style="border-left: none">姓名</th> <th style="width: 20px">年齡</th> <th style="width: 200px">出生年月</th> <th style="width: 20px">手機號碼</th> <th style="width: 20px">單位</th> <th>姓名</th> <th>年齡</th> <th>出生年月</th> <th>手機號碼</th> <th>單位</th> <th>姓名</th> <th>年齡</th> <th>出生年月</th> <th>手機號碼</th> <th>單位</th> <th>姓名</th> <th>年齡</th> <th>出生年月</th> </tr> </thead> <tbody></tbody> </table> </body> </html> <script src="@Rison.Utilities.Resource.referenceUri/scripts/jquery/jquery-1.8.2.js" type="text/javascript"></script> <script type="text/javascript"> //頁面加載 $(function () { var html = ""; var url = '../ProductAutoPurchase/List1'; $.ajax({ type: 'POST', url: url, success: function (data) { for (var i = 0; i < data.rows.length; i++) { var row = data.rows[i]; var trColor; //table--隔行變色 if (i % 2 == 0) { trColor = "even"; } else { trColor = "odd"; } html += "<tr class='" + trColor + "'>"; html += '<td style="border-left: none ">' + row.ProductSkuId + '</td>'; html += '<td style="width: 20px">' + row.ProductSkuCode + '</td>'; html += '<td style="width: 200px">' + row.ProductSkuFullName + '</td>'; html += '<td style="width: 20px">' + row.ProductSkuCode + '</td>'; html += '<td style="width: 20px">' + row.ProductSkuCode + '</td>'; html += '<td>' + row.ProductSkuCode + '</td>'; html += '<td>' + row.ProductSkuCode + '</td>'; html += '<td>' + row.ProductSkuCode + '</td>'; html += '<td>' + row.ProductSkuCode + '</td>'; html += '<td>' + row.ProductSkuCode + '</td>'; html += '<td>' + row.ProductSkuCode + '</td>'; html += '<td>' + row.ProductSkuCode + '</td>'; html += '<td>' + row.ProductSkuCode + '</td>'; html += '<td>' + row.ProductSkuCode + '</td>'; html += '<td>' + row.ProductSkuCode + '</td>'; html += '<td>' + row.ProductSkuCode + '</td>'; html += '<td>' + row.ProductSkuCode + '</td>'; html += '<td>' + row.ProductSkuCode + '</td>'; html += '</tr>'; } $("#tableValue").append(html); } }); }); </script>