// this leave a white space for days of pervious month. while (weekdays>0){ htmlContent +="<td class='monthPre'></td>";// used in next loop. weekdays--;}// loop to build the calander body. while (counter <= numOfDays){// When to start new line. if (weekdays2 > 6){ weekdays2 = 0; htmlContent +="</tr><tr>";}