国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁(yè) > 編程 > JavaScript > 正文

jQuery UI 實(shí)例講解 - 日期選擇器(Datepicker)

2019-11-19 15:25:26
字體:
來(lái)源:轉(zhuǎn)載
供稿:網(wǎng)友

默認(rèn)功能

日期選擇器(Datepicker)綁定到一個(gè)標(biāo)準(zhǔn)的表單 input 字段上。把焦點(diǎn)移到 input 上(點(diǎn)擊或者使用 tab 鍵),在一個(gè)小的覆蓋層上打開(kāi)一個(gè)交互日歷。選擇一個(gè)日期,點(diǎn)擊頁(yè)面上的任意地方(輸入框即失去焦點(diǎn)),或者點(diǎn)擊 Esc 鍵來(lái)關(guān)閉。如果選擇了一個(gè)日期,則反饋顯示為 input 的值。

<!doctype html> <html lang="en"> <head>  <meta charset="utf-8">  <title>jQuery UI 日期選擇器(Datepicker) - 默認(rèn)功能</title>  <link rel="stylesheet"  rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" 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="http://code.jquery.com/jquery-1.9.1.js"></script>  <script src="http://code.jquery.com/ui/1.10.4/jquery-ui.js"></script>  <link rel="stylesheet"  rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" 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> 

  

動(dòng)畫(huà)

當(dāng)打開(kāi)或關(guān)閉 datepicker 時(shí)使用不同的動(dòng)畫(huà)。從下拉框中選擇一個(gè)動(dòng)畫(huà),然后在輸入框中點(diǎn)擊來(lái)查看它的效果。您可以使用三個(gè)標(biāo)準(zhǔn)動(dòng)畫(huà)中任意一個(gè),或者使用 UI 特效中的任意一個(gè)。

<!doctype html> <html lang="en"> <head>  <meta charset="utf-8">  <title>jQuery UI 日期選擇器(Datepicker) - 動(dòng)畫(huà)</title>  <link rel="stylesheet"  rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" 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="http://code.jquery.com/jquery-1.9.1.js"></script>  <script src="http://code.jquery.com/ui/1.10.4/jquery-ui.js"></script>  <link rel="stylesheet"  rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" 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>動(dòng)畫(huà):<br>  <select id="anim">   <option value="show">Show (默認(rèn))</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 滑動(dòng)特效)</option>   <option value="">無(wú)</option>  </select> </p>   </body> </html>

其他月份的日期

datepicker 可以顯示其他月份的日期,這些日期也可以設(shè)置成可選擇的。

<!doctype html> <html lang="en"> <head>  <meta charset="utf-8">  <title>jQuery UI 日期選擇器(Datepicker) - 其他月份的日期</title>  <link rel="stylesheet"  rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" 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="http://code.jquery.com/jquery-1.9.1.js"></script>  <script src="http://code.jquery.com/ui/1.10.4/jquery-ui.js"></script>  <link rel="stylesheet"  rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" 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> 

顯示按鈕欄

通過(guò)布爾值的 showButtonPanel 選項(xiàng)為選擇當(dāng)天日期顯示一個(gè)"Today"按鈕,為關(guān)閉日歷顯示一個(gè)"Done"按鈕。默認(rèn)情況下,當(dāng)按鈕欄顯示時(shí)會(huì)啟用每個(gè)按鈕,但是按鈕可通過(guò)其他的選項(xiàng)進(jìn)行關(guān)閉。按鈕文本可自定義。

<!doctype html> <html lang="en"> <head>  <meta charset="utf-8">  <title>jQuery UI 日期選擇器(Datepicker) - 顯示按鈕欄</title>  <link rel="stylesheet"  rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" 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="http://code.jquery.com/jquery-1.9.1.js"></script>  <script src="http://code.jquery.com/ui/1.10.4/jquery-ui.js"></script>  <link rel="stylesheet"  rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" 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>

內(nèi)聯(lián)顯示

datepicker 是嵌套在頁(yè)面中顯示,而不是顯示在一個(gè)覆蓋層中。只需要簡(jiǎn)單地在 div 上調(diào)用 .datepicker() 即可,而不是在 input 上調(diào)用。

<!doctype html> <html lang="en"> <head>  <meta charset="utf-8">  <title>jQuery UI 日期選擇器(Datepicker) - 內(nèi)聯(lián)顯示</title>  <link rel="stylesheet"  rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" 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="http://code.jquery.com/jquery-1.9.1.js"></script>  <script src="http://code.jquery.com/ui/1.10.4/jquery-ui.js"></script>  <link rel="stylesheet"  rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" 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>  日期:<div id="datepicker"></div>   </body> </html> 

顯示月份 & 年份菜單

顯示月份和年份的下拉框,而不是顯示靜態(tài)的月份/年份標(biāo)題,這樣便于在大范圍的時(shí)間跨度上導(dǎo)航。添加布爾值 changeMonth和 changeYear 選項(xiàng)即可。

<!doctype html> <html lang="en"> <head>  <meta charset="utf-8">  <title>jQuery UI 日期選擇器(Datepicker) - 顯示月份 & 年份菜單</title>  <link rel="stylesheet"  rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" 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="http://code.jquery.com/jquery-1.9.1.js"></script>  <script src="http://code.jquery.com/ui/1.10.4/jquery-ui.js"></script>  <link rel="stylesheet"  rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" 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> 

顯示多個(gè)月份

設(shè)置 numberOfMonths 選項(xiàng)為一個(gè)整數(shù) 2,或者大于 2 的整數(shù),來(lái)在一個(gè) datepicker 中顯示多個(gè)月份。

<!doctype html> <html lang="en"> <head>  <meta charset="utf-8">  <title>jQuery UI 日期選擇器(Datepicker) - 顯示多個(gè)月份</title>  <link rel="stylesheet"  rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" 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="http://code.jquery.com/jquery-1.9.1.js"></script>  <script src="http://code.jquery.com/ui/1.10.4/jquery-ui.js"></script>  <link rel="stylesheet"  rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" 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> 

格式化日期

以各種方式顯示日期反饋。從下拉框中選擇一種日期格式,然后在輸入框中點(diǎn)擊并選擇一個(gè)日期,查看所選格式的日期顯示。

<!doctype html> <html lang="en"> <head>  <meta charset="utf-8">  <title>jQuery UI 日期選擇器(Datepicker) - 格式化日期</title>  <link rel="stylesheet"  rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" 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="http://code.jquery.com/jquery-1.9.1.js"></script>  <script src="http://code.jquery.com/ui/1.10.4/jquery-ui.js"></script>  <link rel="stylesheet"  rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" 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>格式選項(xiàng):<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="'day' d 'of' MM 'in the year' yy">With text - 'day' d 'of' MM 'in the year' yy</option>  </select> </p>   </body> </html>

圖標(biāo)觸發(fā)器

點(diǎn)擊輸入框旁邊的圖標(biāo)來(lái)顯示 datepicker。設(shè)置 datepicker 在獲得焦點(diǎn)時(shí)打開(kāi)(默認(rèn)行為),或者在點(diǎn)擊圖標(biāo)時(shí)打開(kāi),或者在獲得焦點(diǎn)/點(diǎn)擊圖標(biāo)時(shí)打開(kāi)。

<!doctype html> <html lang="en"> <head>  <meta charset="utf-8">  <title>jQuery UI 日期選擇器(Datepicker) - 圖標(biāo)觸發(fā)器</title>  <link rel="stylesheet"  rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" 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="http://code.jquery.com/jquery-1.9.1.js"></script>  <script src="http://code.jquery.com/ui/1.10.4/jquery-ui.js"></script>  <link rel="stylesheet"  rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" 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 日歷語(yǔ)言和格式(默認(rèn)為 English / Western 格式)。datepicker 包含對(duì)從右到左讀取的語(yǔ)言的內(nèi)建支持,比如 Arabic 和 Hebrew。

<!doctype html> <html lang="en"> <head>  <meta charset="utf-8">  <title>jQuery UI 日期選擇器(Datepicker) - 本地化日歷</title>  <link rel="stylesheet"  rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" 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="http://code.jquery.com/jquery-1.9.1.js"></script>  <script src="http://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"  rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" 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 (繁

主站蜘蛛池模板:
和田市|
城固县|
西乡县|
元氏县|
随州市|
天祝|
通榆县|
时尚|
平邑县|
商都县|
忻州市|
五常市|
呼伦贝尔市|
遂宁市|
拜城县|
永嘉县|
凤山市|
阜南县|
哈尔滨市|
蓬安县|
新安县|
廊坊市|
阿勒泰市|
洛浦县|
军事|
德州市|
从化市|
永吉县|
九台市|
于都县|
陆川县|
尉氏县|
牙克石市|
阿鲁科尔沁旗|
兴宁市|
清水县|
枣强县|
宁南县|
锡林郭勒盟|
微山县|
友谊县|