Quantcast
Channel: Active questions tagged html - Stack Overflow
Viewing all articles
Browse latest Browse all 67527

print calendar vertically using jquery

$
0
0

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.


Viewing all articles
Browse latest Browse all 67527

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>