gpt4 book ai didi

javascript - 带有工具提示的 Jquery 范围 slider

转载 作者:搜寻专家 更新时间:2023-11-01 04:37:35 25 4
gpt4 key购买 nike

我使用带有范围 slider ( slider 上有 2 个 handle )的 Jquery Ui 来过滤最小值和最大值。但是,不知道如何为两个 handle 添加工具提示,因为 slider 本身不支持带有 slider 的工具提示。

最佳答案

.ui-slider-handle 类在用作范围时有两个项目。因此,您必须正确使用 .first().last() 方法以获得最小和最大范围处理程序。

这是 jsFiddle example .

这是这个 question 的答案的修改版本:

    var tooltipmin = $('<div id="tooltip" />').css({
position: 'absolute',
top: -25,
left: -10
}).hide();
var tooltipmax = $('<div id="tooltip" />').css({
position: 'absolute',
top: -25,
left: -10
}).hide();
var slideritem = $("#slider").slider({
values: [350, 500],
min: 0,
max: 1000,
step: 50,
range: true,
slide: function(event, ui) {
tooltipmin.text(ui.values[0]);
tooltipmax.text(ui.values[1]);
},
change: function(event, ui) {
tooltipmin.text(ui.values[0]);
tooltipmax.text(ui.values[1]);
}
});
slideritem
.find(".ui-slider-handle")
.first()
.append(tooltipmin)
.hover(function() {
tooltipmin.show();
tooltipmax.show();
}, function() {
tooltipmin.hide();
tooltipmax.hide();
});
slideritem
.find(".ui-slider-handle")
.last()
.append(tooltipmax)
.hover(function() {
tooltipmin.show();
tooltipmax.show();
}, function() {
tooltipmin.hide();
tooltipmax.hide();
});

关于javascript - 带有工具提示的 Jquery 范围 slider ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17339694/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com