gpt4 book ai didi

Javascript:在特定单元格中写入

转载 作者:行者123 更新时间:2023-11-28 12:42:28 25 4
gpt4 key购买 nike

所以我的 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);
}

有人可以告诉我我在这里做错了什么,因为我的代码根本没有写入我的单元格吗?

最佳答案

我收到 JavaScript 错误:

Uncaught TypeError: Object Wed Jun 27 2012 14:14:28 GMT+0100 (BST) has no method 'GetDate' 

当我运行它时。我相信该方法是 getDate() ,并带有一个小 g 来表示 get。

Javascript 控制台是你的 friend 。 :)

关于Javascript:在特定单元格中写入,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11226989/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com