简体   繁体   English

如何使用输入类型日期将日期输入到日历中

[英]how to use input type date to input dates into a calendar

I was wondering how I would go about making a birthday calendar where I can insert dates (using JS, HTML and CSS).我想知道如何制作一个可以插入日期的生日日历(使用 JS、HTML 和 CSS)。 I already have a full calendar.我已经有一个完整的日历。 I just dont know how to use input type date to insert a date into it.我只是不知道如何使用输入类型日期将日期插入其中。 Thanks谢谢

You can attach an event listener to the input field and write an appropriate event handler that processes your date.您可以将事件侦听器附加到输入字段并编写处理您的日期的适当事件处理程序。

See the code below that logs the selected date on the console.请参阅下面在控制台上记录所选日期的代码。

 $("#date").on('change', (event) => { const date = $(event.target).val(); // You can do whatever you want with this date console.log(date); });
 <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <input type="date" id="date" />

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

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