jQuery Mobile - 資料選擇器控制元件



描述

DatePicker 函式可以與使用 JqueryUI 的控制元件一併使用,因為它不支援 jQuery mobile 控制元件。它用於聚焦於輸入,以在小疊加中開啟一個互動式日曆。

彈出式資料選擇器

當輸入獲得焦點以插入日期時,日曆會彈出。在 <input> 欄位中新增 data-role = "date" 屬性可插入日期,以 dd/mm/yy 格式顯示。

示例

以下示例演示如何在 jQuery Mobile 中使用彈出式資料選擇器

<!DOCTYPE html>
<html>
   <head>
      <meta name = "viewport" content = "width = device-width, initial-scale = 1">
      <link rel = "stylesheet" href = "https://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.css">
      <link rel = "stylesheet" href = "https://rawgithub.com/arschmitz/jquery-mobile-datepicker-wrapper/master/jquery.mobile.datepicker.css" />
      <script src = "https://code.jquery.com/jquery-1.11.3.min.js"></script>
      <script src = "https://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.js"></script>
      <script src = "https://rawgithub.com/jquery/jquery-ui/1-10-stable/ui/jquery.ui.datepicker.js"></script>
      <script src = "https://rawgithub.com/arschmitz/jquery-mobile-datepicker-wrapper/master/jquery.mobile.datepicker.js"></script>
   </head>
      
   <body>
      <h2>Popup Datapicker Example</h2>
      <form>
         <input type = "text" data-role = "date">
      </form>
   </body>
</html>

輸出

讓我們執行以下步驟,瞭解 obve 程式碼如何執行 −

  • 將上述 html 程式碼另存為伺服器根資料夾中的 popup_datapicker.html 檔案。

  • 將此 HTML 檔案開啟為 https:///popup_datapicker.html,將顯示以下輸出。

內聯資料選擇器

包含 data-inline = "true" 以顯示互動式日曆。

示例

以下示例演示如何在 jQuery Mobile 中使用內聯資料選擇器。

<!DOCTYPE html>
<html>
   <head>
      <meta name = "viewport" content = "width = device-width, initial-scale = 1">
      <link rel = "stylesheet" href = "https://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.css">
      <link rel = "stylesheet" href = "https://rawgithub.com/arschmitz/jquery-mobile-datepicker-wrapper/master/jquery.mobile.datepicker.css" />
      <script src = "https://code.jquery.com/jquery-1.11.3.min.js"></script>
      <script src = "https://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.js"></script>
      <script src = "https://rawgithub.com/jquery/jquery-ui/1-10-stable/ui/jquery.ui.datepicker.js"></script>
      <script src = "https://rawgithub.com/arschmitz/jquery-mobile-datepicker-wrapper/master/jquery.mobile.datepicker.js"></script>
   </head>
   
   <body>
      <h2>Popup Datapicker Example</h2>
      <form>
         <input type = "text" data-role = "date" data-inline = "true">
      </form>
   </body>
</html>

輸出

讓我們執行以下步驟,瞭解 obve 程式碼如何執行 −

  • 將上述 html 程式碼另存為伺服器根資料夾中的 inline_datapicker.html 檔案。

  • 將此 HTML 檔案開啟為 https:///inline_datapicker.html,將顯示以下輸出。

jquery_mobile_widgets.htm
廣告
© . All rights reserved.