「jQuery」カレンダーDatepickerに表示する月分を指定するサンプル

環境
jquery 3.6.0
Google Chrome 104.0.5112.81

書式
numberOfMonths:数値の月

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
numberOfMonthsに2を指定する場合、2ヶ月分表示されます。
numberOfMonthsを使って、カレンダーに表示する月を増やします。
numberOfMonthsに2を指定する場合、2ヶ月分表示されます。 numberOfMonthsを使って、カレンダーに表示する月を増やします。
numberOfMonthsに2を指定する場合、2ヶ月分表示されます。
numberOfMonthsを使って、カレンダーに表示する月を増やします。

使用例

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.12.1/themes/smoothness/jquery-ui.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1/i18n/jquery.ui.datepicker-ja.min.js"></script>
<script>
$(function() {
/*カレンダーに表示する月を増やす設定*/
var regFrom = $("#search").datepicker({
//表示される月の数
  numberOfMonths:2
});
});
</script>
</head>
<body>
<!--テキスト入力欄 -->
<p>検索日: <input type="text" id="search" /></p>
</body>
</html>
<!DOCTYPE html> <html> <head> <link rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.12.1/themes/smoothness/jquery-ui.css"> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script> <script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js"></script> <script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1/i18n/jquery.ui.datepicker-ja.min.js"></script> <script> $(function() { /*カレンダーに表示する月を増やす設定*/ var regFrom = $("#search").datepicker({ //表示される月の数   numberOfMonths:2 }); }); </script> </head> <body> <!--テキスト入力欄 --> <p>検索日: <input type="text" id="search" /></p> </body> </html>
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.12.1/themes/smoothness/jquery-ui.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1/i18n/jquery.ui.datepicker-ja.min.js"></script>
<script>
$(function() {
  /*カレンダーに表示する月を増やす設定*/
  var regFrom = $("#search").datepicker({
     //表示される月の数
     numberOfMonths:2
    });
});
</script>
</head>
<body>
<!--テキスト入力欄 -->
<p>検索日: <input type="text" id="search" /></p>
</body>
</html>

結果
「検索日」欄をクリックしたら、2ヶ月分表示されます。

jQuery

Posted by arkgame