admin管理员组文章数量:1290263
i need my calendar to go to the current date when [today] button is clicked, so that the user can get to the current day when browsing my calendar.
for example the current month is feb 2013 and the user is browsing on the dec 2015 page of the calendar when he clicks the [today] button it will automatically return to the current days page of the calendar which is feb 2013.
i'am using
jquery-ui-datepicker.min.js
as a plugin for my calendar
i need my calendar to go to the current date when [today] button is clicked, so that the user can get to the current day when browsing my calendar.
for example the current month is feb 2013 and the user is browsing on the dec 2015 page of the calendar when he clicks the [today] button it will automatically return to the current days page of the calendar which is feb 2013.
i'am using
jquery-ui-datepicker.min.js
as a plugin for my calendar
Share Improve this question edited Feb 15, 2013 at 8:44 Darren 70.8k24 gold badges140 silver badges145 bronze badges asked Feb 15, 2013 at 8:27 telexpertelexper 2,44110 gold badges39 silver badges66 bronze badges2 Answers
Reset to default 8The jQuery UI Datepicker has functionality built into it for this.
See this: http://jqueryui./datepicker/#buttonbar
$(function() {
$( "#datepicker" ).datepicker({
showButtonPanel: true
});
});
You could do:
function TodaysDate() {
var currentTime = new Date()
var month = currentTime.getMonth() + 1
var day = currentTime.getDate()
var year = currentTime.getFullYear()
return month + "/" + day + "/" + year;
}
$("#btnToday").click(function() {
var today = new Date();
$(target).datepicker('setDate', TodaysDate());
}
Where target
is your date picker control ID.
本文标签: javascriptjquery ui datepicker go to today buttonStack Overflow
版权声明:本文标题:javascript - jquery ui datepicker go to today button - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741492041a2381666.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论