jQuery Mobile - 滑塊基礎



描述

  • 若要新增滑塊小部件,請使用有 type = "range" 屬性的 input。

  • 指定 minmax 值以設定滑塊的範圍。

  • 滑塊的初始值在 value 屬性中設定。

示例

以下示例演示了在 jQuery Mobile 中使用 基本滑塊

<!DOCTYPE html>
<html>
   <head>
      <title>Basic Slider</title>
      <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>
         <label for = "slider1">Slider:</label>
         <input type = "range" name = "slider1" id = "slider1" min = "0" max = "100" 
            value = "60">
      </form>
   </body>
</html>

輸出

讓我們執行以下步驟,看看上面的程式碼如何工作 -

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

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

jquery_mobile_widgets.htm
廣告
© . All rights reserved.