javascript - 日本日期选择器日历

标签 javascript html jquery css geolocation

原始问题

我已阅读 jQuery Datepicker Japanese Calendar , jquery japanese datepicker , https://jqueryui.com/datepicker/#localization和其他来源,但仍然无法让我的日历正确显示日期。

  <link rel="stylesheet" href="//code.jquery.com/ui/1.13.0/themes/base/jquery-ui.css">
  <link rel="stylesheet" href="/resources/demos/style.css">
  <script src="https://code.jquery.com/jquery-3.6.0.js"></script>
  <script src="https://code.jquery.com/ui/1.13.0/jquery-ui.js"></script>
  <script src="i18n/datepicker-ja.js"></script>





<script>
  $( function() {
    $( "#datepicker" ).datepicker( $.datepicker.regional[ "ja" ] );
   
  } );
  </script>
</head>
<body>
 
<p>Date: <input type="text" id="datepicker">

</p>
 
 
</body>
</html>

enter image description here

更新

我认为我的谷歌浏览器出现了奇怪的故障,我不得不进入设置并点击“重置并清理”。我多说说here .

最佳答案

您可以包含对以下语言的内置支持:

/* Japanese initialisation for the jQuery UI date picker plugin. */
jQuery(function($){
    $.datepicker.regional['ja'] = {
        closeText: '閉じる',
        prevText: '&#x3c;前',
        nextText: '次&#x3e;',
        currentText: '今日',
        monthNames: ['1月','2月','3月','4月','5月','6月',
        '7月','8月','9月','10月','11月','12月'],
        monthNamesShort: ['1月','2月','3月','4月','5月','6月',
        '7月','8月','9月','10月','11月','12月'],
        dayNames: ['日曜日','月曜日','火曜日','水曜日','木曜日','金曜日','土曜日'],
        dayNamesShort: ['日','月','火','水','木','金','土'],
        dayNamesMin: ['日','月','火','水','木','金','土'],
        weekHeader: '週',
        dateFormat: 'yy/mm/dd',
        firstDay: 0,
        isRTL: false,
        showMonthAfterYear: true,
        yearSuffix: '年'};
    $.datepicker.setDefaults($.datepicker.regional['ja']);
});
$( function() {
    $( "#datepicker" ).datepicker( $.datepicker.regional[ "ja" ] );
   
  } );
<html>
  <head>
    <link rel="stylesheet" href="//code.jquery.com/ui/1.13.0/themes/base/jquery-ui.css">
    <link rel="stylesheet" href="/resources/demos/style.css">
    <script src="https://code.jquery.com/jquery-3.6.0.js"></script>
    <script src="https://code.jquery.com/ui/1.13.0/jquery-ui.js"> </script>
  </head>
  <body> 
    <p>Date: <input type="text" id="datepicker"></p>
  </body>
</html>

其他解决方案,您可以使用更改日期选择器区域的选项:

$(function() {
    $("#datepicker").datepicker();
    $("#datepicker").datepicker("option", $.datepicker.regional["ja"])
});
<link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1/themes/ui-lightness/jquery-ui.css" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.0/jquery.min.js" referrerpolicy="no-referrer"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js" integrity="sha512-uto9mlQzrs59VwILcLiRYeLKPPbS/bT71da/OEBYEwcdNUk8jYIy+D176RYoop1Da+f9mvkYrmj5MCLZWEtQuA==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.16/i18n/jquery-ui-i18n.min.js"></script>

Date: <input id="datepicker" type="text">

关于javascript - 日本日期选择器日历,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/69814034/

相关文章:

javascript - 响应圈图像?

javascript - 仅当前一个功能已成功完成时,如何正确触发此功能?

javascript - Laravel 405 方法不允许通过 GET 调用 POST 方法

javascript - AWS dynamodb 使用 "on-demand"ProvisionedThroughput 创建表

javascript - 使用jquery检查按钮是否被点击

javascript - 如果从特定 URL 定向到该页面,则取消脚本

javascript - Angularjs $window.open 弹出窗口被阻止

html - 图片改变div位置

html - 如何更改单选按钮 'selected' 状态外观?

html - HTML 和 CSS 中的全屏代码