简体   繁体   English

如何在文本框中显示日历单击html

[英]how to show calendar on text box click in html

In html i want to show calendar to select date while clicking a text box. 在html中,我想显示日历以选择日期,同时单击文本框。 then we select a date from that calendar then the selected date will be display in that text box. 然后我们从该日历中选择一个日期,然后所选日期将显示在文本框中。

Starting with HTML5, <input type="date" /> will do just fine. 从HTML5开始, <input type="date" />就可以了。

Demo: http://jsfiddle.net/8N6KH/ 演示: http//jsfiddle.net/8N6KH/

You should read-up on jQueryUI Datepicker 你应该阅读jQueryUI Datepicker

Once you include the relevant jQuery UI library, it's as simple as, 一旦你包含了相关的jQuery UI库,它就像,

Script: 脚本:

$(function() {
    $( "#datepicker" ).datepicker();
});

HTML: HTML:

<input type="text" id="datepicker" />

Pros: 优点:

  • it is thoroughly tested for x-browser compatibility, so you won't have a problem. 它经过了x-browser兼容性的全面测试,因此您不会遇到任何问题。
  • Separate css file, so you can customize it as per your liking 单独的css文件,因此您可以根据自己的喜好自定义它

try to use jquery-ui 尝试使用jquery-ui

<script src="http://code.jquery.com/ui/1.10.1/jquery-ui.js"></script>

<script>   
    $(function() {
         $( "#calendar" ).datepicker();   
    }); 
</script>

<p>Calendar: <input type="text" id="calendar" /></p>

more 更多

What you need is a jQuery UI Datepicker 你需要的是一个jQuery UI Datepicker

Check out the demo and the source code. 查看演示和源代码。

You will need to use any javascript html calendar widget. 您将需要使用任何javascript html日历小部件。

try this calendar view widget , just copy-paste some code shown in example there and thats it what you want. 尝试这个日历视图小部件 ,只需复制粘贴示例中显示的一些代码,这就是你想要的。

Here is the link to Jquery Mobile date box - JQM datebox 这是Jquery Mobile日期框的链接 - JQM日期框

yeah you will come across of various issues using HTML5 datepicker, it would work with some or might not be. 是的,你会遇到使用HTML5 datepicker的各种问题,它可以与一些或不一致。 I faced the same issue. 我遇到了同样的问题。 Please check this DatePicker Demo , I solved my problem with this plugin. 请检查这个DatePicker演示 ,我用这个插件解决了我的问题。 Its very good and flexible datepicker plugin with complete demo. 它非常好,灵活的datepicker插件,完整的演示。 It is completely compatible with mobile browsers too and can be integrated with jquery mobile too. 它也与移动浏览器完全兼容,也可以与jquery mobile集成。

HTML日期选择器您可以参考这个

jQuery Mobile has a datepicker too. jQuery Mobile也有一个日期选择器。 Source 资源

Just include the following files, 只需包含以下文件,

  <script src="jQuery.ui.datepicker.js"></script>
  <script src="jquery.ui.datepicker.mobile.js"></script>

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

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