0

我在我的 web 应用程序上使用 TimePicker 插件:http: //trentrichardson.com/examples/timepicker/ 它工作得很好,除了“现在”按钮的默认行为不是我想要的。

至于普通的 DatePicker,我发现这段代码效果很好:

jQuery.datepicker._gotoToday = function ( id )
{
    var target = jQuery( id );
    var inst = this._getInst( target[0] );
    if ( this._get( inst, 'gotoCurrent' ) && inst.currentDay )
    {
        inst.selectedDay = inst.currentDay;
        inst.drawMonth = inst.selectedMonth = inst.currentMonth;
        inst.drawYear = inst.selectedYear = inst.currentYear;
    }
    else
    {
        var date = new Date();
        inst.selectedDay = date.getDate();
        inst.drawMonth = inst.selectedMonth = date.getMonth();
        inst.drawYear = inst.selectedYear = date.getFullYear();
        this._setDateDatepicker( target, date );
        this._selectDate( id, this._getDateDatepicker( target ) );
    }
    this._notifyChange( inst );
    this._adjustDate( target );
};

不幸的是,TimePicker 不适合。有人可以提供我可以用于 TimePicker 插件的类似代码吗?

4

0 回答 0