javascript を使用してカレンダーを開発したいのですが、状況にどのようにアプローチすればよいかわかりません。つまり、2 つの矢印 (左に 1 つ、右に 1 つ) を使用して月と年を切り替えたいと考えています。日が表示されます。右矢印を押して次の月などに切り替えるにはどうすればよいですか?
1 に答える
1
しばらく前に、この種のことをサポートするためにjQuery datepickerを変更しました。私はgitなどにソースを持っていないので、ここにあります:http://jsfiddle.net/ZUrJY/2/
変更の関連部分は_generateHTML
メソッドにあります。
var prev = (this._canAdjustMonth(inst, -1, drawYear, drawMonth) ?
'<a style="left: 22px;" class="ui-datepicker-prev ui-corner-all" onclick="DP_jQuery_' + dpuuid +
'.datepicker._adjustDate(\'#' + inst.id + '\', -' + stepMonths + ', \'M\');"' +
' title="' + prevText + '"><span class="ui-icon ui-icon-circle-triangle-' + (isRTL ? 'e' : 'w') + '">' + prevText + '</span></a>' :
(hideIfNoPrevNext ? '' : '<a style="left: 22px;" class="ui-datepicker-prev ui-corner-all ui-state-disabled" title="' + prevText + '"><span class="ui-icon ui-icon-circle-triangle-' + (isRTL ? 'e' : 'w') + '">' + prevText + '</span></a>'));
prev += (this._canAdjustMonth(inst, -12, drawYear, drawMonth) ?
'<a class="ui-datepicker-prev ui-corner-all" onclick="DP_jQuery_' + dpuuid +
'.datepicker._adjustDate(\'#' + inst.id + '\', -' + 12 + ', \'M\');"' +
' title="Prev Year"><span class="ui-icon ui-icon-circle-arrow-' + (isRTL ? 'e' : 'w') + '">Prev Year</span></a>' :
(hideIfNoPrevNext ? '' : '<a class="ui-datepicker-prev ui-corner-all ui-state-disabled" title="Prev Year"><span class="ui-icon ui-icon-circle-arrow-' + (isRTL ? 'e' : 'w') + '">' + prevText + '</span></a>'));
var nextText = this._get(inst, 'nextText');
nextText = (!navigationAsDateFormat ? nextText : this.formatDate(nextText,
this._daylightSavingAdjust(new Date(drawYear, drawMonth + stepMonths, 1)),
this._getFormatConfig(inst)));
var next = (this._canAdjustMonth(inst, +1, drawYear, drawMonth) ?
'<a style="right: 22px;" class="ui-datepicker-next ui-corner-all" onclick="DP_jQuery_' + dpuuid +
'.datepicker._adjustDate(\'#' + inst.id + '\', +' + stepMonths + ', \'M\');"' +
' title="' + nextText + '"><span class="ui-icon ui-icon-circle-triangle-' + (isRTL ? 'w' : 'e') + '">' + nextText + '</span></a>' :
(hideIfNoPrevNext ? '' : '<a style="right: 22px;" class="ui-datepicker-next ui-corner-all ui-state-disabled" title="' + nextText + '"><span class="ui-icon ui-icon-circle-triangle-' + (isRTL ? 'w' : 'e') + '">' + nextText + '</span></a>'));
next += (this._canAdjustMonth(inst, +1, drawYear, drawMonth) ?
'<a class="ui-datepicker-next ui-corner-all" onclick="DP_jQuery_' + dpuuid +
'.datepicker._adjustDate(\'#' + inst.id + '\', +' + 12 + ', \'M\');"' +
' title="Next Year"><span class="ui-icon ui-icon-circle-arrow-' + (isRTL ? 'w' : 'e') + '">Next Year</span></a>' :
(hideIfNoPrevNext ? '' : '<a class="ui-datepicker-next ui-corner-all ui-state-disabled" title="Next Year"><span class="ui-icon ui-icon-circle-arrow-' + (isRTL ? 'w' : 'e') + '">' + nextText + '</span></a>'));
于 2012-05-11T20:38:32.307 に答える