0

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

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

4

2 回答 2

4

我收到 javascript 错误:

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

当我运行它时。我相信这个方法是getDate()用一个小g的获取。

Javascript 控制台是您的朋友。:)

于 2012-06-27T13:12:09.003 回答
2

控制台说:

Uncaught TypeError: Object (...) has no method 'GetDate'

改用getDate:http: //jsfiddle.net/6axfn/1/

于 2012-06-27T13:14:59.137 回答