JavaScript 中的日历小部件

发布于 2024-09-25 19:16:22 字数 292 浏览 2 评论 0 原文

使用 JavaScript 创建日历(例如 jquery Datepicker )的最佳方法是什么,我可以在其中添加更多功能?

我想在其中显示一些不同颜色的日期数组以及选择一个日期。

我应该尝试编辑源代码,还是更好地使用一些库并自己完成?

对于第一种情况,我想找到一些关于 jquery Datepicker 源的良好文档。对于第二个,我想找到一些库,它可以创建一个良好且易于使用的日历。

What is the best way to create a calendar with JavaScript like the jquery Datepicker where I can add some more functionality?

I want to display some arrays of dates in different colors in it as well as selecting a date.

Shall I try to edit the source code, or better, use some library and do it myself?

For the first case I would like to find some good documentation of the jquery Datepicker source. For the second I would like to find some library, which creates a good and easy to use calendar.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

作业与我同在 2024-10-02 19:16:22

我想在其中显示一些不同颜色的日期数组并选择一个日期。

jQueryUI 的 datepicker 已经有了这个。

疯狂演示

$(function() {
    var someDates = ['10/8/2010', '10/28/2010', '10/30/2010']; // the array of dates
    
    $("#datepicker").datepicker({
        beforeShowDay: function(date) {
            for (var i = 0; i < someDates.length; i++) {
                if (new Date(someDates[i]).toString() == date.toString()) {

                    return [true,'someDates']; // someDates here is a class
                    // with that added class you could do your style..
                    // html would then be rendered something like this,
                    // <td class="someDates"><a href="">8</a></td>
                }
            }
            return [true];
        }
    });
});​

,你可以更多。尝试阅读 event-beforeShowDay

I want to display some arrays of dates in different colors in it as well as selecting a date.

jQueryUI's datepicker already have this.

crazy demo

$(function() {
    var someDates = ['10/8/2010', '10/28/2010', '10/30/2010']; // the array of dates
    
    $("#datepicker").datepicker({
        beforeShowDay: function(date) {
            for (var i = 0; i < someDates.length; i++) {
                if (new Date(someDates[i]).toString() == date.toString()) {

                    return [true,'someDates']; // someDates here is a class
                    // with that added class you could do your style..
                    // html would then be rendered something like this,
                    // <td class="someDates"><a href="">8</a></td>
                }
            }
            return [true];
        }
    });
});​

and you could do more. Try reading event-beforeShowDay

☆獨立☆ 2024-10-02 19:16:22

如果您不介意自己编写一些代码,可以尝试我的 calendar-logic.js

它根本没有 UI。您将完全控制日历的外观和行为,而不必担心一个月有多少周等背后的数学。

If you don't mind writing some code of your own, you could try my calendar-logic.js.

It does no UI at all. You'll get full control of the look and behaviour of the calendar, without having to worry about the math behind how many weeks there are in a month, etc.

暮凉 2024-10-02 19:16:22

jQuery Datepicker 小部件已经为日历提供了足够的功能。添加自定义颜色更多的是一种样式(因此是 CSS)的事情。此外,文档很容易找到, 也是如此谷歌搜索它

最后,编辑源代码从来都不是一个好主意,因为升级会覆盖您的更改。

The jQuery Datepicker widget already provides enough functionality for a calendar. Adding custom colors is more of a style (thus CSS) thing. Also, documentation is very easy to find, so is Googling for it.

Lastly, editing the source code is never a good idea, since an upgrade will overwrite your changes.

忘年祭陌 2024-10-02 19:16:22

看看 extjs 日历 - 它看起来更具可扩展性 - 并且还有一个专业版本(付费)

http://www.sencha.com/blog/2010/09/08/ext-js-3-3-calendar-component/

Have a look at the extjs calendar - it looks far more extensible - and there is a pro version (paid for ) as well

http://www.sencha.com/blog/2010/09/08/ext-js-3-3-calendar-component/

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文