JQuery Mobile UI DatePicker更改日期格式
问题描述:
我正在尝试更改JQM UI Datepicker中的日期格式。JQuery Mobile UI DatePicker更改日期格式
它有一个输入显示的日期,你改变它们。
我需要它以dd/mm/yyyy格式显示。
任何人都可以帮忙吗?
UPDATE:
我想这一点,但什么也没有发生变化:
<script>
//reset type=date inputs to text
$(document).bind("mobileinit", function(){
$.mobile.page.prototype.options.degradeInputs.date = true;
});
</script>
<script language="javascript">
$(document).ready(function() {
$.datepicker.formatDate('dd/mm/yyyy'); //ADDED HERE
$("input[type='submit']").click(function(e) {
e.preventDefault();
});
});
</script>
答
更改“jquery.ui.datepicker。 mobile.js“文件
添加日期格式:dateFormat:“dd/mm/yy”代码如下所示代码
//bind to pagecreate to automatically enhance date inputs
$(".ui-page").live("pagecreate", function(){
$("input[type='date'], input[data-type='date']").each(function(){
$(this).after($("<div />").datepicker({ altField: "#" + $(this).attr("id"), showOtherMonths: true, dateFormat: "dd/mm/yy" }));
});
});
您可能会失败。一旦创建了控件,它似乎不会让您进行更改 - 我遇到过类似的问题。 http://stackoverflow.com/questions/5898535/changing-jquery-mobile-date-picker-options – Rob 2011-05-26 19:19:14