Javascript 如何更改日期选择器日期格式?
默认情况下,的格式是MM/DD/YYYY,我希望它是DD/MM/YYYY,是否有办法更改它?如果无法将区域设置更改为DD/MM/YYYY,可以尝试将日期选择器绑定子类化并重写Javascript 如何更改日期选择器日期格式?,javascript,xul,Javascript,Xul,默认情况下,的格式是MM/DD/YYYY,我希望它是DD/MM/YYYY,是否有办法更改它?如果无法将区域设置更改为DD/MM/YYYY,可以尝试将日期选择器绑定子类化并重写\u init方法。您需要设置以下属性: this._separatorFirst.value = '/'; this._separatorSecond.value = '/'; this.dayField = document.getAnonymousElementByAttribute(this, "anonid", "
\u init
方法。您需要设置以下属性:
this._separatorFirst.value = '/';
this._separatorSecond.value = '/';
this.dayField = document.getAnonymousElementByAttribute(this, "anonid", "input-one");
this.monthField = document.getAnonymousElementByAttribute(this, "anonid", "input-two");
this.yearField = document.getAnonymousElementByAttribute(this, "anonid", "input-three");
this.yearField.parentNode.className = "datetimepicker-input-subbox datetimepicker-year";
this.yearField.size = 4;
this.yearField.maxLength = 4;
this.yearLeadingZero = true;
this.monthLeadingZero = true;
this.dayLeadingZero = true;
this._fieldAMPM.parentNode.collapsed = true;
还考虑将增强请求提交到属性和/或属性覆盖格式。
<代码>。选择器< /代码>指的是什么?当我添加$(“.selector”).datepicker({dateFormat:'yy-mm-dd'})时,它没有任何效果代码>到我的脚本。另外,我要找的是显示DD/MM/YYYY格式的日期选择器,而不仅仅是在我读取日期选择器时获取此格式。选择器是您识别特定选择器的方式……因此,也许您可以使用\myDatePickerID
或.myDatePickerClass
来代替.selector