0
我需要將我生成的數據插入到表和錶行中。正如你所看到的,它只有一個邊框。我需要它看起來整潔。任何想法如何做到這一點?如何在jquery中的表中插入生成的數據
這是我一直在玩代碼:
HTML:
<input id="from" />
<input id="to" />
<button id="getBetween">Get Between Dates</button>
<div id=""></div>
<input type="text" id="count" />
<table border="1" >
<tr id="results">
<td></td>
</tr>
</table>
的Jquery:
(function() {
Date.prototype.toYMD = Date_toYMD;
function Date_toYMD() {
var year, month, day;
year = String(this.getFullYear());
month = String(this.getMonth() + 1);
if (month.length == 1) {
month = "0" + month;
}
day = String(this.getDate());
if (day.length == 1) {
day = "0" + day;
}
return year + "-" + month + "-" + day;
}
})();
$("#from").datepicker();
$("#to").datepicker();
$('#getBetween').on('click', function() {
var start = $("#from").datepicker('getDate');
var end = $("#to").datepicker('getDate');
var currentDate = new Date(start);
var between = [];
// alert(start);
// alert(end);
while (currentDate <= end) {
var a = new Date(currentDate);
var b = a.toYMD();
between.push(b);
currentDate.setDate(currentDate.getDate() + 1);
}
$('#results').html(between.join('</br></table> '));
$('#count').val(between.length);
});
感謝,並有一個愉快的一天!
嗨。感謝您的答覆。你的代碼有效。但是如果我想讓桌子垂直而不是水平呢?這是我的小提琴。 http://jsfiddle.net/TMsXM/240/ – jjydummya 2014-09-02 01:21:56