jQuery Mobile - 文字輸入日期時間



描述

輸入中的 datetime 型別屬性定義了日期和時間控制元件。日期和時間(年、月、日、時、分、秒、幾分之一秒)根據 ISO 8601 編碼,時區設定為 UTC。

示例

以下示例演示了在 jQuery Mobile 中使用 datetime 輸入。

<!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">
      <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>
   </head>
   
   <body>
      <form>
         <h2>Datetime Input Example</h2>
         <label for = "src">Datetime Input</label>
         <input type = "datetime" id = "src" data-clear-btn = "false">

         <label for = "src1">Clear the Datetime Field</label>
         <input type = "datetime" data-clear-btn = "true" id = "src1">

         <label for = "src2">Datetime Local Input</label>
         <input type = "datetime-local" id = "src2" data-clear-btn = "false">

         <label for = "src3">Clear the Datetime Local Field</label>
         <input type = "datetime-local" data-clear-btn = "true" id = "src3">
      </form>
   </body>
</html>

輸出

讓我們執行以下步驟,瞭解上述程式碼如何工作 −

  • 將上面的 HTML 程式碼另存為 textinput_datetime.html 檔案,並將其儲存在伺服器根資料夾中。

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

jquery_mobile_widgets.htm
廣告
© . All rights reserved.