我正在开发一个日期选择器日历,用于添加上一个和下一个日期功能,点击按钮。我尝试过PHP和JS,但都没有成功。
window.onload = function () {
let today = new Date();
let D = String(today.getDate()).padStart(2, '0');
let M = String(today.getMonth() + 1).padStart(2, '0'); //January is 0!
let YYYY = today.getFullYear();
today = YYYY + '-' + M + '-' + D;
let today2 = new Date();
today2 = M + "/" + D + "/" + YYYY;
var prevday = new Date();
prevday.setDate(prevday.getDate() - 1);
var nextday = new Date();
nextday.setDate(nextday.getDate() + 1)
addRow('<tr><td colspan="2"><h3>Eventsz for <a href="#" id="datepick1" class="fa fa-chevron-left lg" title="Previous Date"></a>'+ ' ' + today2 + ' ' + '<a href="#" id="prev" class="fa fa-chevron-right lg" title="Next Date"></h3></td></tr>');
不知道这是否是拼写错误,但在您的代码段中,您缺少了一个尾随的}
。
window.onload = function () {
let today = new Date();
let D = String(today.getDate()).padStart(2, '0');
let M = String(today.getMonth() + 1).padStart(2, '0'); //January is 0!
let YYYY = today.getFullYear();
today = YYYY + '-' + M + '-' + D;
let today2 = new Date();
today2 = M + "/" + D + "/" + YYYY;
var prevday = new Date();
prevday.setDate(prevday.getDate() - 1);
var nextday = new Date();
nextday.setDate(nextday.getDate() + 1)
} // Missing
// addRow('<tr><td colspan="2"><h3>Eventsz for <a href="#" id="datepick1" class="fa fa-chevron-left lg" title="Previous Date"></a>'+ ' ' + today2 + ' ' + '<a href="#" id="prev" class="fa fa-chevron-right lg" title="Next Date"></h3></td></tr>');