所以我在我的 div 表中有这个单元格:
<body>
<div>
<table id="TableName" width="auto">
<thead>
<tr>
...
<th colspan="7" style="background-color: black; color: white; text-align: left;">
<div id="last_thursday" />
</th>
</tr>
这段代码将最后一个星期四的日期值写入其中。
$(document).ready(Main);
function Main() {
ConfigDate();
}
function ConfigDate() {
var currentTime = new Date();
var dayofWeek = currentTime.getDay();
var daysSinceThursday = (dayofWeek + 3) % 7
var lastThursday = new Date(currentTime.GetDate() - daysSinceThursday);
var dd = lastThursday.getDate();
var mm = lastThursday.getMonth() + 1;
var yyyy = lastThursday.getFullYear();
$("#last_thursday").text(yyyy + " / " + mm + " / " + dd);
}
有人可以告诉我我在这里做错了什么,因为我的代码根本没有写在我的单元格中吗?