jQuery Mobile - 範圍滑塊步長屬性



說明

你可以透過向輸入新增 step 屬性,強制滑塊沿特定增量捕捉。

示例

以下示例演示了在 jQuery Mobile 中使用 rangeslider step attribute

<!DOCTYPE html>
<html>
   <head>
      <title>Rangeslider 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>
         <div data-role = "rangeslider">
            <label for = "range-1">Rangeslider:</label>
            <input type = "range" name = "range-1" id = "range-1" min = "0" max = "10" 
               step = ".1" value = "6.2">
            <label for = "range-2">Rangeslider:</label>
            <input type = "range" name = "range-2" id = "range-2" min = "0" max = "10" 
               step = ".1" value = "7.8">
         </div>
      </form>
   </body>
</html>

輸出

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

  • 將上述 HTML 程式碼作為 **range_slider_step.html** 檔案儲存到伺服器根資料夾中。

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

jquery_mobile_widgets.htm
廣告
© . All rights reserved.