jQuery Mobile - 文字輸入檔案



說明

file 型別屬性使使用者能夠將檔案上傳到 MIME 型別伺服器。已上傳的檔案可以是文字檔案、影像檔案或任何文件。

示例

以下示例演示了在 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>File Input Example</h2>
         <label for = "src">File Input</label>
         <input type = "file" id = "src" data-clear-btn = "false">

         <label for = "src1">Clear the File Field</label>
         <input type = "file" data-clear-btn = "true" id = "src1">
      </form>
   </body>
</html>

輸出

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

  • 將上述 html 程式碼另存為 textinput_file.html 檔案,並儲存到伺服器根資料夾中。

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

jquery_mobile_widgets.htm
廣告
© . All rights reserved.