我对jQuery很陌生,我知道答案已经在这里回答了:
jQuery UI datepicker: How to change the month names in the drop-down from short to long names?但它与我想要的无关。
问题很简单:如何在datepicker中使用monthNames代替monthNamesShort。 (我可以修改语言文件,但我不想这样做(因为以后,我网站的用户将可以在短或全月名称之间进行选择))
如果您需要一些代码,我会给您一些代码:


  Javascript:


datepicker.regional[ "en-GB" ] = {
closeText: "Done",
prevText: "Prev",
nextText: "Next",
currentText: "Today",
monthNames: [ "January","February","March","April","May","June",
"July","August","September","October","November","December" ],
monthNamesShort: [ "Jan", "Feb", "Mar", "Apr", "May", "Jun",
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec" ],
dayNames: [ "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" ],
dayNamesShort: [ "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" ],
dayNamesMin: [ "Su","Mo","Tu","We","Th","Fr","Sa" ],
weekHeader: "Wk",
dateFormat: "dd/mm/yy",
firstDay: 1,
isRTL: false,
showMonthAfterYear: false,
yearSuffix: "" };
datepicker.setDefaults( datepicker.regional[ "en-GB" ] );



  范本(HTML):


$( "#datepicker1" ).datepicker({changeMonth: true,changeYear: true,showOtherMonths: true,selectOtherMonths: true});
        $( "#datepicker1" ).datepicker("option","monthNames","dateFormat","yy-mm-dd","firstDay",1);


您也可以给我一个想法,使用dayNames代替默认的dayNamesMin。 (例如,删除monthNamesShort无效,并显示默认值之一,而不是按GB收费)
如果您知道更改默认语法(在HTML中首选)的语法,将欢迎您提供任何帮助。谢谢

最佳答案

月份的下拉列表默认使用monthNamesShort,因此您需要将其替换为monthNames
fiddle

$.datepicker.regional[ "en-GB" ] = {
        closeText: "Done",
        prevText: "Prev",
        nextText: "Next",
        currentText: "Today",
        monthNames: [ "January","February","March","April","May","June",
        "July","August","September","October","November","December" ],
        monthNamesShort: [ "Jan", "Feb", "Mar", "Apr", "May", "Jun",
        "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" ],
        dayNames: [ "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" ],
        dayNamesShort: [ "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" ],
        dayNamesMin: [ "Su","Mo","Tu","We","Th","Fr","Sa" ],
        weekHeader: "Wk",
        dateFormat: "dd/mm/yy",
        firstDay: 1,
        isRTL: false,
        showMonthAfterYear: false,
        yearSuffix: "" };
      $.datepicker.setDefaults( $.datepicker.regional[ "en-GB" ] );

    var fullmonthnames =  $.datepicker.regional[ "en-GB" ].monthNames;
    $.datepicker.setDefaults($.datepicker.regional[ "en-GB" ] );

          $( "#datepicker1" ).datepicker({
              monthNamesShort: fullmonthnames,
              changeMonth: true,
              changeYear: true,
              showOtherMonths: true,
              selectOtherMonths: true
             });

关于javascript - jQuery UI datepicker(以HTML格式):如何使用monthNames代替monthNamesShort?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/38204954/

10-08 23:09