我有一个datepicker实例,我希望能够更改月份名称。我该怎么做?
我已经尝试了,但我不确定我做错了什么。
我的尝试:
<script>
$(function() {
$( "#datepicker" ).datepicker({
altField: "#alternate",
});
});
$( ".selector" ).datepicker({
monthNames: [ "Test1", "Test2", "Test3", "Test4", "Test5", "Test6",
"Test7", "Test8", "Test9", "Test10", "Test11", "Test12" ]
});
var monthNames = $( ".selector" ).datepicker( "option", "monthNames" );
$( ".selector" ).datepicker( "option", "monthNames",
[ "Test1", "Test2", "Test3", "Test4", "Test5", "Test6",
"Test7", "Test8", "Test9", "Test10", "Test11", "Test12" ] );
</script>
答案 0 :(得分:2)
datePicker触发器函数应位于document.ready()内,并按monthNames:
更改monthNamesShort:
属性
<script>
$(function () {
$("#datepicker").datepicker({
altField: "#alternate",
});
$(".selector").datepicker({
monthNamesShort: ["Test1", "Test2", "Test3", "Test4", "Test5", "Test6", "Test7", "Test8", "Test9", "Test10", "Test11", "Test12"]
});
var monthNames = $(".selector").datepicker("option", "monthNames");
$(".selector").datepicker("option", "monthNames", ["Test1", "Test2", "Test3", "Test4", "Test5", "Test6", "Test7", "Test8", "Test9", "Test10", "Test11", "Test12"]);
});
</script>