简体   繁体   English

如何在HTML中实现日历?

[英]How to implement a calendar in HTML?

I have a web application that uses HTML and Javascript. 我有一个使用HTML和Javascript的Web应用程序。 I want to create a textbox that allows to user to enter in a keyword and submit it. 我想创建一个文本框,允许用户输入关键字并提交。 I also want a little calendar icon next to the textbox so the user can click on it to popup a calendar to select a date as the keyword, and then submit that. 我还想在文本框旁边放一个小日历图标,以便用户可以单击它以弹出日历以选择日期作为关键字,然后提交。

I have tried to implement Jcalendar and DatePicker but couldn't get either one working. 我试图实现Jcalendar和DatePicker,但无法使其中任何一个工作。

Is there something that I can use that will meet my needs? 有什么东西可以用来满足我的需求吗? Thank you! 谢谢!

The easiest way is jQuery's Date Picker . 最简单的方法是jQuery的Date Picker One line of code....done. 一行代码....完成。

<script type="text/javascript">
$( "#datepicker" ).datepicker();
</script>

查看jQueryUI datepicker: http//jqueryui.com/demos/datepicker/

Try the jquery ui datepicker 试试jquery ui datepicker

http://jqueryui.com/demos/datepicker/ http://jqueryui.com/demos/datepicker/

Something a bit like this? 有点像这样吗?

http://jqueryui.com/demos/datepicker/ http://jqueryui.com/demos/datepicker/

Have a look at jQuery UI's calendar with an icon-trigger. 使用图标触发器查看jQuery UI的日历

To have an icon trigger the calender, it would be something like this: 要有一个图标触发日历,它将是这样的:

<script type="text/javascript">
    $(function() {
        $( "#idOfYourInput" ).datepicker({
            showOn: "button",
            buttonImage: "images/calendar.gif",
            buttonImageOnly: true
        });
    });
</script>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM