I was trying to print calendar vertically like this
1 8 15 22 29
2 9 16 23 30
3 10 17 24 31
4 11 18 25
5 12 19 26
6 13 20 27
7 14 21 28
I tried below code
var x = 1;
var $tbodyTr = $('<tr>').appendTo($tbody);
for(var i = 1; i <= 31; i++){
if(x == 7) {
x = 1;
$tbodyTr = $('<tr>').appendTo($tbody);
}
$tbodyTd = $('<td>',{html: i}).appendTo($tbodyTr);
x++;
}
But it prints horizontally.
var $table = $('<table>',{'class': 'table-calendar table table-hover text-center table-calendar'});
var $tbody = $('<tbody>').appendTo($table);
var x = 1;
var $tbodyTr = $('<tr>').appendTo($tbody);
for(var i = 1; i <= 31; i++){
if(x == 7) {
x = 1;
$tbodyTr = $('<tr>').appendTo($tbody);
}
$tbodyTd = $('<td>',{html: i}).appendTo($tbodyTr);
x++;
}
$('.table-responsive').html($table);
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script><div class="table-responsive"></div>
Looking for help, want vertical output.