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.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 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 文件打开为 http://localhost/slider_tooltip.html,将显示以下输出。