ホームページ > ウェブフロントエンド > jsチュートリアル > jQuery UI の日付ピッカーの例の詳細な説明

jQuery UI の日付ピッカーの例の詳細な説明

小云云
リリース: 2018-02-06 09:15:52
オリジナル
1542 人が閲覧しました

デフォルト関数

Datepicker は標準フォーム入力フィールドにバインドされています。フォーカスを入力に移動すると (クリックまたはタブ キーを使用)、小さなオーバーレイでインタラクティブなカレンダーが開きます。日付を選択し、ページ上の任意の場所をクリックするか (入力ボックスはフォーカスを失います)、Esc キーを押して閉じます。日付を選択した場合、フィードバックが入力値として表示されます。

この記事では主に jQuery UI - Datepicker (Datepicker) の例を紹介します。編集者はこれが非常に良いものだと思ったので、皆さんの参考として今から共有します。編集者をフォローして見てみましょう。皆さんのお役に立てれば幸いです。


1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

<!doctype html>

<html lang="en">

<head>

 <meta charset="utf-8">

 <title>jQuery UI 日期选择器(Datepicker) - 默认功能</title>

 <link rel="stylesheet" href="//code.jquery.com/ui/1.10.4/themes/smoothness/jquery-ui.css" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >

 <script src="//code.jquery.com/jquery-1.9.1.js"></script>

 <script src="//code.jquery.com/ui/1.10.4/jquery-ui.js"></script>

 <link rel="stylesheet" href="http://jqueryui.com/resources/demos/style.css" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >

 <script>

 $(function() {

 $( "#datepicker" ).datepicker();

 });

 </script>

</head>

<body>

  

<p>日期:<input type="text" id="datepicker"></p>

  

  

</body>

</html>

ログイン後にコピー

アニメーション

日付ピッカーを開いたり閉じたりするときに、さまざまなアニメーションを使用します。ドロップダウン ボックスからアニメーションを選択し、入力ボックスをクリックしてその効果を確認します。 3 つの標準アニメーションのいずれかを使用することも、UI 効果のいずれかを使用することもできます。


1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

<!doctype html>

<html lang="en">

<head>

 <meta charset="utf-8">

 <title>jQuery UI 日期选择器(Datepicker) - 动画</title>

 <link rel="stylesheet" href="//code.jquery.com/ui/1.10.4/themes/smoothness/jquery-ui.css" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >

 <script src="//code.jquery.com/jquery-1.9.1.js"></script>

 <script src="//code.jquery.com/ui/1.10.4/jquery-ui.js"></script>

 <link rel="stylesheet" href="http://jqueryui.com/resources/demos/style.css" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >

 <script>

 $(function() {

  $( "#datepicker" ).datepicker();

  $( "#anim" ).change(function() {

   $( "#datepicker" ).datepicker( "option", "showAnim", $( this ).val() );

  });

 });

 </script>

</head>

<body>

  

<p>日期:<input type="text" id="datepicker" size="30"></p>

  

<p>动画:<br>

 <select id="anim">

  <option value="show">Show (默认)</option>

  <option value="slideDown">滑下</option>

  <option value="fadeIn">淡入</option>

  <option value="blind">Blind (UI 百叶窗特效)</option>

  <option value="bounce">Bounce (UI 反弹特效)</option>

  <option value="clip">Clip (UI 剪辑特效)</option>

  <option value="drop">Drop (UI 降落特效)</option>

  <option value="fold">Fold (UI 折叠特效)</option>

  <option value="slide">Slide (UI 滑动特效)</option>

  <option value="">无</option>

 </select>

</p>

  

  

</body>

</html>

ログイン後にコピー

他の月の日付

datepicker は他の月の日付を表示でき、これらの日付を選択可能に設定することもできます。


1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

<!doctype html>

<html lang="en">

<head>

 <meta charset="utf-8">

 <title>jQuery UI 日期选择器(Datepicker) - 其他月份的日期</title>

 <link rel="stylesheet" href="//code.jquery.com/ui/1.10.4/themes/smoothness/jquery-ui.css" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >

 <script src="//code.jquery.com/jquery-1.9.1.js"></script>

 <script src="//code.jquery.com/ui/1.10.4/jquery-ui.js"></script>

 <link rel="stylesheet" href="http://jqueryui.com/resources/demos/style.css" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >

 <script>

 $(function() {

 $( "#datepicker" ).datepicker({

  showOtherMonths: true,

  selectOtherMonths: true

 });

 });

 </script>

</head>

<body>

  

<p>日期:<input type="text" id="datepicker"></p>

  

  

</body>

</html>

ログイン後にコピー

ボタンバーを表示

ブール値の showButtonPanel オプションを使用して、今日の日付を選択するための「今日」ボタンとカレンダーを閉じるための「完了」ボタンを表示します。デフォルトでは、ボタン バーが表示されているときに各ボタンが有効になりますが、追加のオプションを使用してボタンをオフにすることができます。ボタンのテキストはカスタマイズ可能です。


1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

<!doctype html>

<html lang="en">

<head>

 <meta charset="utf-8">

 <title>jQuery UI 日期选择器(Datepicker) - 显示按钮栏</title>

 <link rel="stylesheet" href="//code.jquery.com/ui/1.10.4/themes/smoothness/jquery-ui.css" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >

 <script src="//code.jquery.com/jquery-1.9.1.js"></script>

 <script src="//code.jquery.com/ui/1.10.4/jquery-ui.js"></script>

 <link rel="stylesheet" href="http://jqueryui.com/resources/demos/style.css" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >

 <script>

 $(function() {

 $( "#datepicker" ).datepicker({

  showButtonPanel: true

 });

 });

 </script>

</head>

<body>

  

<p>日期:<input type="text" id="datepicker"></p>

  

  

</body>

</html>

ログイン後にコピー

インライン表示

datepicker は、オーバーレイに表示されるのではなく、ページ内にネストされて表示されます。 input の代わりに p で .datepicker() を呼び出すだけです。


1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

<!doctype html>

<html lang="en">

<head>

 <meta charset="utf-8">

 <title>jQuery UI 日期选择器(Datepicker) - 内联显示</title>

 <link rel="stylesheet" href="//code.jquery.com/ui/1.10.4/themes/smoothness/jquery-ui.css" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >

 <script src="//code.jquery.com/jquery-1.9.1.js"></script>

 <script src="//code.jquery.com/ui/1.10.4/jquery-ui.js"></script>

 <link rel="stylesheet" href="http://jqueryui.com/resources/demos/style.css" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >

 <script>

 $(function() {

 $( "#datepicker" ).datepicker();

 });

 </script>

</head>

<body>

  

日期:<p id="datepicker"></p>

  

  

</body>

</html>

ログイン後にコピー

月と年のメニューを表示

静的な月/年のヘッダーの代わりに月と年のドロップダウンボックスを表示し、長い期間にわたるナビゲーションを容易にします。ブール値のchangeMonthおよびchangeyearオプションを追加するだけです。


1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

<!doctype html>

<html lang="en">

<head>

 <meta charset="utf-8">

 <title>jQuery UI 日期选择器(Datepicker) - 显示月份 & 年份菜单</title>

 <link rel="stylesheet" href="//code.jquery.com/ui/1.10.4/themes/smoothness/jquery-ui.css" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >

 <script src="//code.jquery.com/jquery-1.9.1.js"></script>

 <script src="//code.jquery.com/ui/1.10.4/jquery-ui.js"></script>

 <link rel="stylesheet" href="http://jqueryui.com/resources/demos/style.css" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >

 <script>

 $(function() {

 $( "#datepicker" ).datepicker({

  changeMonth: true,

  changeYear: true

 });

 });

 </script>

</head>

<body>

  

<p>日期:<input type="text" id="datepicker"></p>

  

  

</body>

</html>

ログイン後にコピー

複数の月を表示する

日付ピッカーで複数の月を表示するには、numberOfMonths オプションを整数 2 または 2 より大きい整数に設定します。


1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

<!doctype html>

<html lang="en">

<head>

 <meta charset="utf-8">

 <title>jQuery UI 日期选择器(Datepicker) - 显示多个月份</title>

 <link rel="stylesheet" href="//code.jquery.com/ui/1.10.4/themes/smoothness/jquery-ui.css" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >

 <script src="//code.jquery.com/jquery-1.9.1.js"></script>

 <script src="//code.jquery.com/ui/1.10.4/jquery-ui.js"></script>

 <link rel="stylesheet" href="http://jqueryui.com/resources/demos/style.css" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >

 <script>

 $(function() {

 $( "#datepicker" ).datepicker({

  numberOfMonths: 3,

  showButtonPanel: true

 });

 });

 </script>

</head>

<body>

  

<p>日期:<input type="text" id="datepicker"></p>

  

  

</body>

</html>

ログイン後にコピー

日付の書式設定

さまざまな方法で日付のフィードバックを表示します。ドロップダウン ボックスから日付形式を選択し、入力ボックスで日付をクリックして選択すると、選択した形式で日付が表示されます。


1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

<!doctype html>

<html lang="en">

<head>

 <meta charset="utf-8">

 <title>jQuery UI 日期选择器(Datepicker) - 格式化日期</title>

 <link rel="stylesheet" href="//code.jquery.com/ui/1.10.4/themes/smoothness/jquery-ui.css" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >

 <script src="//code.jquery.com/jquery-1.9.1.js"></script>

 <script src="//code.jquery.com/ui/1.10.4/jquery-ui.js"></script>

 <link rel="stylesheet" href="http://jqueryui.com/resources/demos/style.css" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >

 <script>

 $(function() {

 $( "#datepicker" ).datepicker();

 $( "#format" ).change(function() {

  $( "#datepicker" ).datepicker( "option", "dateFormat", $( this ).val() );

 });

 });

 </script>

</head>

<body>

  

<p>日期:<input type="text" id="datepicker" size="30"></p>

  

<p>格式选项:<br>

 <select id="format">

 <option value="mm/dd/yy">Default - mm/dd/yy</option>

 <option value="yy-mm-dd">ISO 8601 - yy-mm-dd</option>

 <option value="d M, y">Short - d M, y</option>

 <option value="d MM, y">Medium - d MM, y</option>

 <option value="DD, d MM, yy">Full - DD, d MM, yy</option>

 <option value="&#39;day&#39; d &#39;of&#39; MM &#39;in the year&#39; yy">With text - &#39;day&#39; d &#39;of&#39; MM &#39;in the year&#39; yy</option>

 </select>

</p>

  

  

</body>

</html>

ログイン後にコピー

アイコントリガー

入力ボックスの横にあるアイコンをクリックして、日付ピッカーを表示します。フォーカス時 (デフォルトの動作)、アイコンのクリック時、またはフォーカス/アイコンのクリック時に日付ピッカーが開くように設定します。


1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

<!doctype html>

<html lang="en">

<head>

 <meta charset="utf-8">

 <title>jQuery UI 日期选择器(Datepicker) - 图标触发器</title>

 <link rel="stylesheet" href="//code.jquery.com/ui/1.10.4/themes/smoothness/jquery-ui.css" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >

 <script src="//code.jquery.com/jquery-1.9.1.js"></script>

 <script src="//code.jquery.com/ui/1.10.4/jquery-ui.js"></script>

 <link rel="stylesheet" href="http://jqueryui.com/resources/demos/style.css" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >

 <script>

 $(function() {

 $( "#datepicker" ).datepicker({

  showOn: "button",

  buttonImage: "images/calendar.gif",

  buttonImageOnly: true

 });

 });

 </script>

</head>

<body>

  

<p>日期:<input type="text" id="datepicker"></p>

  

  

</body>

</html>

ログイン後にコピー

ローカライズされたカレンダー

ローカライズされた日付ピッカーのカレンダー言語と形式 (デフォルトは英語/西洋形式)。 datepicker には、アラビア語やヘブライ語など、右から左に読む言語のサポートが組み込まれています。


1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

<!doctype html>

<html lang="en">

<head>

 <meta charset="utf-8">

 <title>jQuery UI 日期选择器(Datepicker) - 本地化日历</title>

 <link rel="stylesheet" href="//code.jquery.com/ui/1.10.4/themes/smoothness/jquery-ui.css" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >

 <script src="//code.jquery.com/jquery-1.9.1.js"></script>

 <script src="//code.jquery.com/ui/1.10.4/jquery-ui.js"></script>

 <script src="http://jqueryui.com/resources/demos/datepicker/jquery.ui.datepicker-ar.js"></script>

 <script src="http://jqueryui.com/resources/demos/datepicker/jquery.ui.datepicker-fr.js"></script>

 <script src="http://jqueryui.com/resources/demos/datepicker/jquery.ui.datepicker-he.js"></script>

 <script src="http://jqueryui.com/resources/demos/datepicker/jquery.ui.datepicker-zh-TW.js"></script>

 <link rel="stylesheet" href="http://jqueryui.com/resources/demos/style.css" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >

 <script>

 $(function() {

 $( "#datepicker" ).datepicker( $.datepicker.regional[ "fr" ] );

 $( "#locale" ).change(function() {

  $( "#datepicker" ).datepicker( "option",

  $.datepicker.regional[ $( this ).val() ] );

 });

 });

 </script>

</head>

<body>

  

<p>日期:<input type="text" id="datepicker">

 <select id="locale">

 <option value="ar">Arabic (?(???????</option>

 <option value="zh-TW">Chinese Traditional (繁體中文)</option>

 <option value="">English</option>

 <option value="fr" selected="selected">French (Fran?ais)</option>

 <option value="he">Hebrew (?(?????</option>

 </select></p>

  

  

</body>

</html>

ログイン後にコピー

別の入力ボックスに入力します

altField オプションと altFormat オプションを使用すると、日付が選択されるたびに、別の入力ボックスに特定の形式の日付が入力されます。この機能は、コンピューターに適した日付によってさらに処理され、ユーザーにわかりやすい日付が表示されます。


1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

<!doctype html>

<html lang="en">

<head>

 <meta charset="utf-8">

 <title>jQuery UI 日期选择器(Datepicker) - 填充另一个输入框</title>

 <link rel="stylesheet" href="//code.jquery.com/ui/1.10.4/themes/smoothness/jquery-ui.css" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >

 <script src="//code.jquery.com/jquery-1.9.1.js"></script>

 <script src="//code.jquery.com/ui/1.10.4/jquery-ui.js"></script>

 <link rel="stylesheet" href="http://jqueryui.com/resources/demos/style.css" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >

 <script>

 $(function() {

 $( "#datepicker" ).datepicker({

  altField: "#alternate",

  altFormat: "DD, d MM, yy"

 });

 });

 </script>

</head>

<body>

  

<p>日期:<input type="text" id="datepicker"> <input type="text" id="alternate" size="30"></p>

  

  

</body>

</html>

ログイン後にコピー

日付範囲を制限する

minDate オプションと maxDate オプションを使用して、選択可能な日付範囲を制限します。開始日と終了日を実際の日付 (new Date(2009, 1 - 1, 26))、今日からの数値オフセット (-20)、または期間と単位の文字列 ('+1M +10D ') に設定します。 )。文字列に設定する場合は、日には「D」、週には「W」、月には「M」、年には「Y」を使用します。


1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

<!doctype html>

<html lang="en">

<head>

 <meta charset="utf-8">

 <title>jQuery UI 日期选择器(Datepicker) - 限制日期范围</title>

 <link rel="stylesheet" href="//code.jquery.com/ui/1.10.4/themes/smoothness/jquery-ui.css" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >

 <script src="//code.jquery.com/jquery-1.9.1.js"></script>

 <script src="//code.jquery.com/ui/1.10.4/jquery-ui.js"></script>

 <link rel="stylesheet" href="http://jqueryui.com/resources/demos/style.css" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >

 <script>

 $(function() {

 $( "#datepicker" ).datepicker({ minDate: -20, maxDate: "+1M +10D" });

 });

 </script>

</head>

<body>

  

<p>日期:<input type="text" id="datepicker"></p>

  

  

</body>

</html>

ログイン後にコピー

日付範囲を選択してください

検索したい日付範囲を選択してください。


1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

<!doctype html>

<html lang="en">

<head>

 <meta charset="utf-8">

 <title>jQuery UI 日期选择器(Datepicker) - 选择一个日期范围</title>

 <link rel="stylesheet" href="//code.jquery.com/ui/1.10.4/themes/smoothness/jquery-ui.css" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >

 <script src="//code.jquery.com/jquery-1.9.1.js"></script>

 <script src="//code.jquery.com/ui/1.10.4/jquery-ui.js"></script>

 <link rel="stylesheet" href="http://jqueryui.com/resources/demos/style.css" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >

 <script>

 $(function() {

 $( "#from" ).datepicker({

  defaultDate: "+1w",

  changeMonth: true,

  numberOfMonths: 3,

  onClose: function( selectedDate ) {

  $( "#to" ).datepicker( "option", "minDate", selectedDate );

  }

 });

 $( "#to" ).datepicker({

  defaultDate: "+1w",

  changeMonth: true,

  numberOfMonths: 3,

  onClose: function( selectedDate ) {

  $( "#from" ).datepicker( "option", "maxDate", selectedDate );

  }

 });

 });

 </script>

</head>

<body>

  

<label for="from">从</label>

<input type="text" id="from" name="from">

<label for="to">到</label>

<input type="text" id="to" name="to">

  

  

</body>

</html>

ログイン後にコピー

年間の週を表示

datepicker は年間の週を表示できます。デフォルトの計算は ISO 8601 の定義に基づいています。つまり、各週は月曜日に始まり、各年の第 1 週にはその年の第 1 木曜日が含まれます。これは、ある年の一部の日が別の年の週に属する可能性があることを意味します。


1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

<!doctype html>

<html lang="en">

<head>

 <meta charset="utf-8">

 <title>jQuery UI 日期选择器(Datepicker) - 显示一年中的第几周</title>

 <link rel="stylesheet" href="//code.jquery.com/ui/1.10.4/themes/smoothness/jquery-ui.css" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >

 <script src="//code.jquery.com/jquery-1.9.1.js"></script>

 <script src="//code.jquery.com/ui/1.10.4/jquery-ui.js"></script>

 <link rel="stylesheet" href="http://jqueryui.com/resources/demos/style.css" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >

 <script>

 $(function() {

 $( "#datepicker" ).datepicker({

  showWeek: true,

  firstDay: 1

 });

 });

 </script>

</head>

<body>

  

<p>日期:<input type="text" id="datepicker"></p>

  

  

</body>

</html>

ログイン後にコピー

jQuery の datepicker が中国語になります: jquery.ui.datepicker-zh-CN.js は通常、この js を探します。この js のコードを取り出します。そのため、オンラインで探す必要はもうありません。


1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

jQuery(function($){

 $.datepicker.regional[&#39;zh-CN&#39;] = {

  closeText: &#39;关闭&#39;,

  prevText: &#39;<上月&#39;,

  nextText: &#39;下月>&#39;,

  currentText: &#39;今天&#39;,

  monthNames: [&#39;一月&#39;,&#39;二月&#39;,&#39;三月&#39;,&#39;四月&#39;,&#39;五月&#39;,&#39;六月&#39;,

  &#39;七月&#39;,&#39;八月&#39;,&#39;九月&#39;,&#39;十月&#39;,&#39;十一月&#39;,&#39;十二月&#39;],

  monthNamesShort: [&#39;一&#39;,&#39;二&#39;,&#39;三&#39;,&#39;四&#39;,&#39;五&#39;,&#39;六&#39;,

  &#39;七&#39;,&#39;八&#39;,&#39;九&#39;,&#39;十&#39;,&#39;十一&#39;,&#39;十二&#39;],

  dayNames: [&#39;星期日&#39;,&#39;星期一&#39;,&#39;星期二&#39;,&#39;星期三&#39;,&#39;星期四&#39;,&#39;星期五&#39;,&#39;星期六&#39;],

  dayNamesShort: [&#39;周日&#39;,&#39;周一&#39;,&#39;周二&#39;,&#39;周三&#39;,&#39;周四&#39;,&#39;周五&#39;,&#39;周六&#39;],

  dayNamesMin: [&#39;日&#39;,&#39;一&#39;,&#39;二&#39;,&#39;三&#39;,&#39;四&#39;,&#39;五&#39;,&#39;六&#39;],

  weekHeader: &#39;周&#39;,

  dateFormat: &#39;yy-mm-dd&#39;,

  firstDay: 1,

  isRTL: false,

  showMonthAfterYear: true,

  yearSuffix: &#39;年&#39;};

 $.datepicker.setDefaults($.datepicker.regional[&#39;zh-CN&#39;]);

});

ログイン後にコピー
関連する推奨事項:

JQuery の書き込み日付ピッカーのサンプル チュートリアル

WeChat アプレット用の日付ピッカーを開発する方法

JSタッチスクリーンWebバージョンアプリのようなポップアップスクロールリストセレクター/日付セレクター

以上がjQuery UI の日付ピッカーの例の詳細な説明の詳細内容です。詳細については、PHP 中国語 Web サイトの他の関連記事を参照してください。

関連ラベル:
このウェブサイトの声明
この記事の内容はネチズンが自主的に寄稿したものであり、著作権は原著者に帰属します。このサイトは、それに相当する法的責任を負いません。盗作または侵害の疑いのあるコンテンツを見つけた場合は、admin@php.cn までご連絡ください。
最新の問題
jQueryファイルをインポートする
から 1970-01-01 08:00:00
0
0
0
jQueryのプロトタイプチェーン
から 1970-01-01 08:00:00
0
0
0
Nuxt.js に jQuery をインストールする手順
から 1970-01-01 08:00:00
0
0
0
php+jqueryの問題
から 1970-01-01 08:00:00
0
0
0
人気のチュートリアル
詳細>
最新のダウンロード
詳細>
ウェブエフェクト
公式サイト
サイト素材
フロントエンドテンプレート