[JS]jQuery Datepickerの日付フォーマットを変更する方法
スポンサード
スポンサード
以前紹介させていただいたjQuery Datepickerですが、カレンダーの日付をクリックして表示される日付のフォーマットをyy/mm/dd
に変更する方法のご紹介です。
jQuery Datepickerの日付フォーマットを変更
前回の記事同様、フォーム部分のHTMLは以下のようなdatepickerのクラス名がついた<input type=text>にします。1 2 3 | <form> <input type="text" size="15" class="datepicker"> </form> |
デフォルトの日付のフォーマットはmm/dd/yyなので、これをyy/mm/dd
に変更したい場合は、ページの<head>内か</body>の上あたりに以下のような記述を行います。
1 2 3 4 5 6 7 8 9 | <link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css"> <script src="https://code.jquery.com/jquery-1.12.4.js"></script> <script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script> <script> $(function() { $(".datepicker").datepicker(); $(".datepicker").datepicker("option", "dateFormat", 'yy/mm/dd' ); }); </script> |
スポンサード
コメント