<span id="mktg5"></span>

<i id="mktg5"><meter id="mktg5"></meter></i>

        <label id="mktg5"><meter id="mktg5"></meter></label>
        最新文章專題視頻專題問答1問答10問答100問答1000問答2000關鍵字專題1關鍵字專題50關鍵字專題500關鍵字專題1500TAG最新視頻文章推薦1 推薦3 推薦5 推薦7 推薦9 推薦11 推薦13 推薦15 推薦17 推薦19 推薦21 推薦23 推薦25 推薦27 推薦29 推薦31 推薦33 推薦35 推薦37視頻文章20視頻文章30視頻文章40視頻文章50視頻文章60 視頻文章70視頻文章80視頻文章90視頻文章100視頻文章120視頻文章140 視頻2關鍵字專題關鍵字專題tag2tag3文章專題文章專題2文章索引1文章索引2文章索引3文章索引4文章索引5123456789101112131415文章專題3
        問答文章1 問答文章501 問答文章1001 問答文章1501 問答文章2001 問答文章2501 問答文章3001 問答文章3501 問答文章4001 問答文章4501 問答文章5001 問答文章5501 問答文章6001 問答文章6501 問答文章7001 問答文章7501 問答文章8001 問答文章8501 問答文章9001 問答文章9501
        當前位置: 首頁 - 科技 - 知識百科 - 正文

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

        來源:懂視網 責編:小采 時間:2020-11-27 22:29:53
        文檔

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

        jQuery UI 實例講解 - 日期選擇器(Datepicker):默認功能 日期選擇器(Datepicker)綁定到一個標準的表單 input 字段上。把焦點移到 input 上(點擊或者使用 tab 鍵),在一個小的覆蓋層上打開一個交互日歷。選擇一個日期,點擊頁面上的任意地方(輸入框即失去焦點),或者點擊 Esc 鍵來關閉。如果選
        推薦度:
        導讀jQuery UI 實例講解 - 日期選擇器(Datepicker):默認功能 日期選擇器(Datepicker)綁定到一個標準的表單 input 字段上。把焦點移到 input 上(點擊或者使用 tab 鍵),在一個小的覆蓋層上打開一個交互日歷。選擇一個日期,點擊頁面上的任意地方(輸入框即失去焦點),或者點擊 Esc 鍵來關閉。如果選

        默認功能

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

        <!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="https://www.gxlcms.com//code.jquery.com/jquery-1.9.1.js"></script> 
         <script src="https://www.gxlcms.com//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> 
        

          

        動畫

        當打開或關閉 datepicker 時使用不同的動畫。從下拉框中選擇一個動畫,然后在輸入框中點擊來查看它的效果。您可以使用三個標準動畫中任意一個,或者使用 UI 特效中的任意一個。

        <!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="https://www.gxlcms.com//code.jquery.com/jquery-1.9.1.js"></script> 
         <script src="https://www.gxlcms.com//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>動畫:<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 可以顯示其他月份的日期,這些日期也可以設置成可選擇的。

        <!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="https://www.gxlcms.com//code.jquery.com/jquery-1.9.1.js"></script> 
         <script src="https://www.gxlcms.com//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> 
        
        

        顯示按鈕欄

        通過布爾值的 showButtonPanel 選項為選擇當天日期顯示一個"Today"按鈕,為關閉日歷顯示一個"Done"按鈕。默認情況下,當按鈕欄顯示時會啟用每個按鈕,但是按鈕可通過其他的選項進行關閉。按鈕文本可自定義。

        <!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="https://www.gxlcms.com//code.jquery.com/jquery-1.9.1.js"></script> 
         <script src="https://www.gxlcms.com//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>

        內聯顯示

        datepicker 是嵌套在頁面中顯示,而不是顯示在一個覆蓋層中。只需要簡單地在 div 上調用 .datepicker() 即可,而不是在 input 上調用。

        <!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="https://www.gxlcms.com//code.jquery.com/jquery-1.9.1.js"></script> 
         <script src="https://www.gxlcms.com//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> 
        

        顯示月份 & 年份菜單

        顯示月份和年份的下拉框,而不是顯示靜態的月份/年份標題,這樣便于在大范圍的時間跨度上導航。添加布爾值 changeMonth和 changeYear 選項即可。

        <!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="https://www.gxlcms.com//code.jquery.com/jquery-1.9.1.js"></script> 
         <script src="https://www.gxlcms.com//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> 
        

        顯示多個月份

        設置 numberOfMonths 選項為一個整數 2,或者大于 2 的整數,來在一個 datepicker 中顯示多個月份。

        <!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="https://www.gxlcms.com//code.jquery.com/jquery-1.9.1.js"></script> 
         <script src="https://www.gxlcms.com//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> 
        

        格式化日期

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

        <!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="https://www.gxlcms.com//code.jquery.com/jquery-1.9.1.js"></script> 
         <script src="https://www.gxlcms.com//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>格式選項:<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>

        圖標觸發器

        點擊輸入框旁邊的圖標來顯示 datepicker。設置 datepicker 在獲得焦點時打開(默認行為),或者在點擊圖標時打開,或者在獲得焦點/點擊圖標時打開。

        <!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="https://www.gxlcms.com//code.jquery.com/jquery-1.9.1.js"></script> 
         <script src="https://www.gxlcms.com//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 日歷語言和格式(默認為 English / Western 格式)。datepicker 包含對從右到左讀取的語言的內建支持,比如 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="https://www.gxlcms.com//code.jquery.com/jquery-1.9.1.js"></script> 
         <script src="https://www.gxlcms.com//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 (繁體中文)</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 選項,無論何時選擇日期,會在另一個輸入框中填充帶有一定格式的日期。這個功能通過對電腦友好性的日期進一步加工后,向用戶呈現一個用戶友好性的日期。

        <!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="https://www.gxlcms.com//code.jquery.com/jquery-1.9.1.js"></script> 
         <script src="https://www.gxlcms.com//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({ 
         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' 表示年。

        <!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="https://www.gxlcms.com//code.jquery.com/jquery-1.9.1.js"></script> 
         <script src="https://www.gxlcms.com//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({ minDate: -20, maxDate: "+1M +10D" }); 
         }); 
         </script> 
        </head> 
        <body> 
         
        <p>日期:<input type="text" id="datepicker"></p> 
         
         
        </body> 
        </html> 
        

        選擇一個日期范圍

        選擇要搜索的日期范圍。

        <!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="https://www.gxlcms.com//code.jquery.com/jquery-1.9.1.js"></script> 
         <script src="https://www.gxlcms.com//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() { 
         $( "#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 定義:每周從星期一開始,每年的第一周包含該年的第一個星期四。這就意味著一年中的一些天可能是屬于另一年中的周。

        <!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="https://www.gxlcms.com//code.jquery.com/jquery-1.9.1.js"></script> 
         <script src="https://www.gxlcms.com//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({ 
         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的代碼拿出來,以后就不需要再在網上找啦:

        jQuery(function($){ 
         $.datepicker.regional['zh-CN'] = { 
         closeText: '關閉', 
         prevText: '<上月', 
         nextText: '下月>', 
         currentText: '今天', 
         monthNames: ['一月','二月','三月','四月','五月','六月', 
         '七月','八月','九月','十月','十一月','十二月'], 
         monthNamesShort: ['一','二','三','四','五','六', 
         '七','八','九','十','十一','十二'], 
         dayNames: ['星期日','星期一','星期二','星期三','星期四','星期五','星期六'], 
         dayNamesShort: ['周日','周一','周二','周三','周四','周五','周六'], 
         dayNamesMin: ['日','一','二','三','四','五','六'], 
         weekHeader: '周', 
         dateFormat: 'yy-mm-dd', 
         firstDay: 1, 
         isRTL: false, 
         showMonthAfterYear: true, 
         yearSuffix: '年'}; 
         $.datepicker.setDefaults($.datepicker.regional['zh-CN']); 
        }); 
        

        以上這篇jQuery UI 實例講解 - 日期選擇器(Datepicker)就是小編分享給大家的全部內容了,希望能給大家一個參考,也希望大家多多支持腳本之家。

        聲明:本網頁內容旨在傳播知識,若有侵權等問題請及時與本網聯系,我們將在第一時間刪除處理。TEL:177 7030 7066 E-MAIL:11247931@qq.com

        文檔

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

        jQuery UI 實例講解 - 日期選擇器(Datepicker):默認功能 日期選擇器(Datepicker)綁定到一個標準的表單 input 字段上。把焦點移到 input 上(點擊或者使用 tab 鍵),在一個小的覆蓋層上打開一個交互日歷。選擇一個日期,點擊頁面上的任意地方(輸入框即失去焦點),或者點擊 Esc 鍵來關閉。如果選
        推薦度:
        • 熱門焦點

        最新推薦

        猜你喜歡

        熱門推薦

        專題
        Top
        主站蜘蛛池模板: 久久久久久国产精品免费免费男同 | 91精品免费不卡在线观看| 免费在线观看a级毛片| 深夜a级毛片免费视频| 国产一级高清免费观看| 特级毛片全部免费播放| 久久久久亚洲精品无码网址| 永久免费无码日韩视频| 亚洲中文久久精品无码ww16| 久久精品无码专区免费| 国产成人亚洲综合无码精品| 久9热免费精品视频在线观看| 久久久久久亚洲Av无码精品专口| 99精品国产成人a∨免费看| 亚洲色图古典武侠| 成年男女免费视频网站| 视频一区在线免费观看| 亚洲色欲久久久综合网| 2015日韩永久免费视频播放| 国产精品久久亚洲不卡动漫| 免费精品国偷自产在线在线| 成年人免费视频观看| 1000部夫妻午夜免费 | 黄色网址免费在线观看| 成全视频在线观看免费| 精品久久久久久久久免费影院| 成人午夜18免费看| 亚洲成a人片在线播放| 亚洲伦理一区二区| 美女露隐私全部免费直播| 热99RE久久精品这里都是精品免费| a视频在线免费观看| 久久久www成人免费毛片| 亚洲毛片αv无线播放一区| 风间由美在线亚洲一区| 亚洲乱码国产一区三区| 国产桃色在线成免费视频 | 亚洲国产成人久久精品影视| 国产免费不卡v片在线观看| 日韩免费码中文在线观看| 亚洲理论精品午夜电影|