Heim  >  Artikel  >  Web-Frontend  >  Ausführliche Erläuterung des Datumswählers Datepicker der jQuery-Benutzeroberfläche

Ausführliche Erläuterung des Datumswählers Datepicker der jQuery-Benutzeroberfläche

小云云
小云云Original
2017-12-29 09:06:351957Durchsuche

Datepicker ist an ein Standard-Formulareingabefeld gebunden. Bewegen Sie den Fokus auf die Eingabe (klicken Sie oder verwenden Sie die Tabulatortaste), um einen interaktiven Kalender in einem kleinen Overlay zu öffnen. Wählen Sie ein Datum aus, klicken Sie auf eine beliebige Stelle auf der Seite (das Eingabefeld verliert den Fokus) oder drücken Sie zum Schließen die Esc-Taste. Wenn ein Datum ausgewählt ist, wird die Rückmeldung als Eingabewert angezeigt. Dieser Artikel enthält hauptsächlich ein Beispiel für die jQuery-Benutzeroberfläche – Datepicker (Datepicker). Der Herausgeber findet es ziemlich gut, deshalb werde ich es jetzt mit Ihnen teilen und es allen als Referenz geben. Folgen wir dem Herausgeber und schauen wir uns das an. Ich hoffe, es kann allen helfen.


<!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>

Animationen

Verwenden Sie unterschiedliche Animationen beim Öffnen oder Schließen der Datumsauswahl. Wählen Sie eine Animation aus dem Dropdown-Feld aus und klicken Sie in das Eingabefeld, um deren Wirkung anzuzeigen. Sie können eine der drei Standardanimationen oder einen der UI-Effekte verwenden.


<!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>

Daten in anderen Monaten

Datumsauswahl kann Daten in anderen Monaten anzeigen, und diese Daten können auch auf festgelegt werden wählbar sein.


<!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>

Schaltflächenleiste anzeigen

Zeigt eine Schaltfläche „Heute“ zur Auswahl des heutigen Datums über die Option „showButtonPanel“ mit booleschem Wert an , Zeigt eine Schaltfläche „Fertig“ zum Schließen des Kalenders an. Standardmäßig ist jede Schaltfläche aktiviert, wenn die Schaltflächenleiste angezeigt wird. Schaltflächen können jedoch über zusätzliche Optionen deaktiviert werden. Der Schaltflächentext ist anpassbar.


<!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>

Inline-Anzeige

Die Datumsauswahl ist in der Seite verschachtelt und wird nicht in einem angezeigt Überlagerung. Rufen Sie einfach .datepicker() auf p anstelle der Eingabe auf.


<!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>

Monats- und Jahresmenü anzeigen

Dropdown-Felder für Monat und Jahr anzeigen statt anzeigen Statische Monats-/Jahrestitel, um die Navigation über große Zeitspannen zu erleichtern. Fügen Sie einfach die booleschen Optionen „changeMonth“ und „changeYear“ hinzu.


<!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>

Mehrere Monate anzeigen

Setzen Sie die Option „numberOfMonths“ auf eine Ganzzahl 2 oder eine Ganzzahl größer als 2 Zeigen Sie mehrere Monate in einer Datumsauswahl an.


<!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>

Daten formatieren

Datumsfeedback auf verschiedene Arten anzeigen. Wählen Sie im Dropdown-Feld ein Datumsformat aus, klicken Sie dann auf und wählen Sie im Eingabefeld ein Datum aus, um die Datumsanzeige im ausgewählten Format anzuzeigen.


<!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>

Symbolauslöser

Klicken Sie auf das Symbol neben dem Eingabefeld, um die Datumsauswahl anzuzeigen. Legt fest, dass die Datumsauswahl beim Fokus (Standardverhalten) oder beim Klicken auf ein Symbol oder beim Klicken auf den Fokus/das Symbol geöffnet wird.


<!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>

Lokalisierter Kalender

Sprache und Format des Lokalisierungskalenders für die Datumsauswahl (Standard ist Englisch/Westformat). Datepicker bietet integrierte Unterstützung für Sprachen, die von rechts nach links gelesen werden, wie etwa Arabisch und Hebräisch.


<!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>

Füllen Sie ein weiteres Eingabefeld aus

Verwenden Sie die Optionen altField und altFormat, wenn Sie ein Datum oder eine andere Eingabe auswählen Das Feld wird mit einem Datum in einem bestimmten Format gefüllt. Diese Funktion wird durch computerfreundliche Daten weiterverarbeitet, um dem Benutzer ein benutzerfreundliches Datum zu präsentieren.


<!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>

Datumsbereich begrenzen

Begrenzen Sie den auswählbaren Datumsbereich über die Optionen minDate und maxDate. Legen Sie das Start- und Enddatum auf tatsächliche Daten (neues Datum (2009, 1 - 1, 26)) oder auf einen numerischen Offset vom heutigen Tag (-20) oder auf eine Zeichenfolge aus Zeitraum und Einheit ('+1M +10D') fest. ). Wenn eine Zeichenfolge festgelegt ist, verwenden Sie „D“ für Tag, „W“ für Woche, „M“ für Monat und „Y“ für Jahr.


<!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>

Wählen Sie einen Datumsbereich aus

Wählen Sie einen Datumsbereich für die Suche aus.


<!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>

Woche des Jahres anzeigen

Datumsauswahl kann die Woche des Jahres anzeigen. Die Standardberechnung basiert auf der ISO 8601-Definition: Jede Woche beginnt am Montag und die erste Woche eines jeden Jahres enthält den ersten Donnerstag dieses Jahres. Das bedeutet, dass einige Tage in einem Jahr zu Wochen in einem anderen Jahr gehören können.


<!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>

Der Datepicker von jQuery wird chinesisch: jquery.ui.datepicker-zh-CN.js sucht normalerweise nach diesem js, ich habe den Code dieses js herausgenommen, Sie Sie müssen nicht mehr online suchen:


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;]); 
});

Verwandte Empfehlungen:

So entwickeln Sie ein WeChat-Applet. Detaillierte Erklärung des Datumsauswahl

React Native Open-Source-Zeit- und Datumsauswahlkomponente

Popup-Bildlaufliste der JS-Touchscreen-Webversion-Imitations-App Auswahl/Datum Pflücker

Das obige ist der detaillierte Inhalt vonAusführliche Erläuterung des Datumswählers Datepicker der jQuery-Benutzeroberfläche. Für weitere Informationen folgen Sie bitte anderen verwandten Artikeln auf der PHP chinesischen Website!

Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn