[英]Distribute table columns equally over the page
我有一個放在桌子上的內容:
<table class="table table-hover" id="anliegenGrammatik"></table>
這是我的jQuery,我有AJAX請求,並使用填充(添加)上表的響應。
success: function(response) {
$.each(response, function(index) {
$.each(response[index].synonyms, function(index2) {
$('#anliegenGrammatik').append('<tr> <td>' + response[index].synonyms[index2] + '</td> </tr>');
});
});
},
但是它有很多數據,像這樣它會產生數百行。 我如何在jQuery中使其在頁面上平均分配列和行。 例如,代替具有一個<tr>
100 <td>
S,我想有4 <tr>
和25 <td>
每一行中第
這有可能嗎?
success: function(response) { $.each(response, function(index) { var item = 1; var totalItems = response[index].synonyms.length; var numRows = 4; // number of rows var cellsRow = Math.floor(totalItems/numRows); // number of cells per row var cells = ''; $.each(response[index].synonyms, function(index2) { cells += '<td>' + response[index].synonyms[index2] + '</td>'; if((item % cellsRow == 0) || item == totalItems) { $('#anliegenGrammatik').append('<tr>'+cells+'</tr>'); cells = ''; } item ++; }); }); },
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.