2013-02-15 86 views
2

我需要我的日曆去當天的日期[今天]按鈕被點擊,以便用戶可以在瀏覽我的日曆時到達當天。jquery ui datepicker去今天按鈕

例如當前月份是2013年2月 和用戶正在瀏覽的2015年12月頁日曆,當他點擊[日]按鈕,它會自動返回到當前天頁面日曆是 feb 2013

使用我'

的jQuery-UI-datepicker.min.js

爲我的日曆插件

回答

1

你可以這樣做:

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()); 
} 

其中target是您的日期選擇器控件ID。

+1

大,做的伎倆 – telexper 2013-02-15 08:34:51