jQuery Mobile - 滑塊步幅屬性



說明

您可以透過向輸入新增 step 屬性來強制滑塊按特定增量進行捕捉。

示例

下面的示例演示了在 jQuery Mobile 中使用 slider step 屬性

<!DOCTYPE html>
<html>
   <head>
      <title>Slider Step Attribute</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 = "10" 
            step = ".1" value = "7.8">
      </form>
      
   </body>
</html>

輸出

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

  • 將上面的 html 程式碼儲存在伺服器的根資料夾中,檔名為 slider_step.html

  • 以 https:///slider_step.html 的形式開啟此 HTML 檔案,將顯示以下輸出。

jquery_mobile_widgets.htm
廣告
© . All rights reserved.