gpt4 book ai didi

javascript - jQuery UI 日期选择器(HTML 格式): How using monthNames instead of monthNamesShort?

转载 作者:行者123 更新时间:2023-11-27 22:48:59 25 4
gpt4 key购买 nike


我对 jQuery 很陌生,我知道答案已经在这里得到了回答: jQuery UI datepicker: How to change the month names in the drop-down from short to long names?但它并不符合我想要的。

问题很简单:如何在日期选择器中使用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" ] );

Template (HTML):

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

您还可以给我一个想法,使用 dayNames 而不是默认的 dayNamesMin。 (例如,删除 MonthNamesShort 不起作用,并显示默认名称而不是 en-GB 收费名称)

如果您知道更改默认值的语法(在 HTML 中首选),我们将欢迎任何帮助。谢谢

最佳答案

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

$.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 日期选择器(HTML 格式): How using monthNames instead of monthNamesShort?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38204954/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com