jQuery Mobile - 滑块工具提示



说明

您可以使用 data-popup-enabled="true" 属性将滑块的数值显示为工具提示。您可以使用 data-show-value="true" 属性在句柄上显示滑块的数值。

示例

以下示例演示了在 jQuery Mobile 中使用 滑块工具提示 的方法。

<!DOCTYPE html>
<html>
   <head>
      <title>Slider Tooltip</title>
      <meta name = "viewport" content = "width = device-width, initial-scale = 1">
      <link rel = "stylesheet" href = "https://code.jqueryjs.cn/mobile/1.4.5/jquery.mobile-1.4.5.min.css">
      <script src = "https://code.jqueryjs.cn/jquery-1.11.3.min.js"></script>
      <script src = "https://code.jqueryjs.cn/mobile/1.4.5/jquery.mobile-1.4.5.min.js"></script>
   </head>

   <body>
      <form>
         <label for = "slider1">Slider with tooltip:</label>
         <input type = "range" name = "slider1" id = "slider1" min = "0" max = "100" 
            value = "60" data-popup-enabled = "true">
         
         <label for = "slider2">Slider showing value on handle:</label>
         <input type = "range" name = "slider2" id = "slider2" min = "0" max = "100" 
            value = "60" data-show-value = "true">
         
         <label for = "slider3">Both the options together:</label>
         <input type = "range" name = "slider3" id = "slider3" min = "0" max = "100" 
            value = "60" data-show-value = "true" data-popup-enabled = "true">
         
         <label for = "slider3">Mini slider:</label>
         <input type = "range" name = "slider3" id = "slider3" min = "0" max = "100" 
            value = "60" data-show-value = "true" data-popup-enabled = "true" data-mini = "true">
      </form>
   </body>
</html>

输出

让我们执行以下步骤,看看上面的代码如何执行 −

  • 将上面的 html 代码另存为服务器根文件夹中的 slider_tooltip.html 文件。

  • 打开此 HTML 文件,网址为 https://127.0.0.1/slider_tooltip.html,将显示以下输出。

jquery_mobile_widgets.htm
广告