使用日期选择器在按钮单击上添加日期范围
我正在尝试通过单击按钮打开带有日期选择器的日历,并在选择时将日期放入同级文本框中。我需要能够对两个不同的文本框执行此操作。
这是我到目前为止所拥有的。
I am trying open a calendar with datepicker on button click, and have the date go into the sibling text box when chosen. I need to be able to do this for two different text boxes.
Here is what I have so far.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要使用该 jsfiddle 加载 jQuery UI。尝试以下操作:
和您的 JS:
需要注意的事项:您不需要添加按钮,日期选择器将为您执行此操作 - 您需要添加指向按钮图像的链接。如果您不喜欢这个,那么您可以删除 bottonImage 引用。
所有这些都取自 jQuery datepicker UI 文档 此处
编辑:
修复了 html 元素的结束标签,已在 jsfiddle 此处 中修复
You need to load the jQuery UI with that jsfiddle. Try the following:
And your JS:
Things to note: you don't need to add the button, the datepicker will do that for you - you'll need to add a link to a button image. If you don't like this then you could just remove the bottonImage reference.
All of this has been taken from the jQuery datepicker UI documentation here
EDIT:
Fixed up closing tags for html elements, fixed in jsfiddle here