首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >日期挑选日月年

问日期挑选日月年
EN

Stack Overflow用户
提问于 2012-05-20 19:08:40
回答 1查看 610关注 0票数 0

http://keith-wood.name/datepick.html

但我能看到的唯一一件事是获取整个时间日月的警报

代码语言:javascript
复制
$(function() {
    $('#popupDatepicker').datepick();
    $('#inlineDatepicker').datepick({onSelect: showDate});
});

function showDate(date) {
    alert('The date chosen is ' + date);
}

我想知道怎样才能让他们分开

代码语言:javascript
复制
<input type="text" name="date" id="popupDatepicker"> When i select date here the fields in the hidden will change below
<input type="hidden" name="day">
<input type="hidden" name="month">
<input type="hidden" name="year">

请指教

EN

回答 1

Stack Overflow用户

发布于 2012-05-20 19:14:53

日期选择器的onselect处理程序的问题是,使用日期选择器上的任何格式将日期作为字符串传递。

您可以使用$('#inlineDatepicker').datepicker('getDate')获取表示所选日期的实际Date对象。

您还可以使用$.datepicker.formatDate()将该对象转换为其他字符串格式,或者使用Date对象自己的方法来提取数值。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/10672889

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档