文字輸入日期、月份和周



描述

日期輸入型別屬性允許使用者輸入按照 ISO 8601 編碼的日期(年、月、日)。

月份輸入型別允許使用者選擇按照 ISO 8601 編碼的由年和月組成的日期。

周輸入型別允許使用者選擇按照 ISO 8601 編碼的由年和週數組成的日期。

示例

下面的示例演示瞭如何在 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">
      <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>Date Input Example</h2>
         <label for = "src">Date Input</label>
         <input type = "date" id = "src" data-clear-btn = "false">
         
         <label for = "src1">Clear the Date input Field</label>
         <input type = "date" data-clear-btn = "true" id = "src1">

         <h2>Month Input Example</h2>
         <label for = "src2">Month Input</label>
         <input type = "month" id = "src2" data-clear-btn = "false">
         
         <label for = "src3">Clear the Month input Field</label>
         <input type = "month" data-clear-btn = "true" id = "src3">

         <h2>Week Input Example</h2>
         <label for = "src4">Week Input</label>
         <input type = "week" id = "src4" data-clear-btn = "false">
         
         <label for = "src5">Clear the Week input Field</label>
         <input type = "week" data-clear-btn = "true" id = "src5">
      </form>
   </body>
</html>

輸出

我們執行以下步驟來了解上述程式碼是如何運作的:-

  • 將以上 html 程式碼作為 textinput_date_month_week.html 檔案儲存在伺服器根資料夾中。

  • 開啟這個 HTML 檔案,網址為 https:///textinput_date_month_week.html,將會顯示以下輸出。

jquery_mobile_widgets.htm
廣告
© . All rights reserved.