admin管理员组文章数量:1305910
I'm trying to get the "shown" month and year after hitting the "next" and "previous" links on the left and right of the date picker header.
Currently I'm using to get the month:
var selectedMonth = $('#calendar').datepicker('getDate').getMonth() + 1;
but it only returns the current month, not the shown month that es with clicking "next" or "prev".
EDIT
I added the onChangeMonthYear
option with the datepicker in the function i have
function getDates() {
var selectedMonth = $('.ui-datepicker-month').text();
var selectedYear = $('.ui-datepicker-year').text();
}
still this just states the current date.
EDITED Again
the above worked just needed to set a delay :]
I'm trying to get the "shown" month and year after hitting the "next" and "previous" links on the left and right of the date picker header.
Currently I'm using to get the month:
var selectedMonth = $('#calendar').datepicker('getDate').getMonth() + 1;
but it only returns the current month, not the shown month that es with clicking "next" or "prev".
EDIT
I added the onChangeMonthYear
option with the datepicker in the function i have
function getDates() {
var selectedMonth = $('.ui-datepicker-month').text();
var selectedYear = $('.ui-datepicker-year').text();
}
still this just states the current date.
EDITED Again
the above worked just needed to set a delay :]
Share Improve this question edited Feb 23, 2013 at 21:55 Matt asked Feb 23, 2013 at 19:29 MattMatt 1051 gold badge1 silver badge8 bronze badges1 Answer
Reset to default 6$.datepicker('getDate')
only returns the selected date of the datepicker, not the month that is currently being shown.
What you're looking for is to bind a function to onChangeMonthYear
. Docs here
Example:
$('#calendar').datepicker('option', 'onChangeMonthYear', function(year, month) { var selectedMonth = month })
本文标签: javascriptjQuery datepicker get month and year shown not currentStack Overflow
版权声明:本文标题:javascript - jQuery datepicker get month and year shown not current - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741810900a2398788.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论