如何确定 jQuery 滑块句柄的优先级?
我有两个滑块手柄,并附加了 。这意味着滑块也可以通过附加的跨度进行控制。
代码如下:
//jquery code
$('#slider').slider({
values: [0, 0]
var handle1 = $('#slider a.ui-slider-handle, ui-state-default, ui-corner-all').first();
handle1.append('<span class="sidecar"></span>');
var handle2 = handle1.next();
handle2.append('<span class="sidecar2"></span>');
}
//css code
.sidecar {
position: absolute;
top: 50px;
left: 0;
width: 20px;
height: 20px;
background: #f00;
}
.sidecar2 {
position: absolute;
top: 80px;
left: 0;
width: 20px;
height: 20px;
background: #000000;
}
当它们彼此重叠时(例如在 (0,0) 处),即使我尝试拖动 '.sidecar2'(黑色),它总是移动带有红色
的滑块。其背后的原因是,它是代码中的第一个句柄,位于两个句柄之间。
我已尽一切努力来修复它。例如,尝试手动将类 ui-state-active ui-state-focus
添加到第二个(黑色)滑块,尝试更改 z-index,但它们都不起作用。 :(
如有任何帮助,我们将不胜感激。
谢谢。
编辑: 我能找到的唯一解决方案在这里给出: 我创建了 2 个滑块,每个滑块都有一个手柄。它工作完美。
I have two slider handles with <span>
appended to them. Meaning sliders can be controlled by attached span as well.
The code is as given:
//jquery code
$('#slider').slider({
values: [0, 0]
var handle1 = $('#slider a.ui-slider-handle, ui-state-default, ui-corner-all').first();
handle1.append('<span class="sidecar"></span>');
var handle2 = handle1.next();
handle2.append('<span class="sidecar2"></span>');
}
//css code
.sidecar {
position: absolute;
top: 50px;
left: 0;
width: 20px;
height: 20px;
background: #f00;
}
.sidecar2 {
position: absolute;
top: 80px;
left: 0;
width: 20px;
height: 20px;
background: #000000;
}
When they are on top of each other(e.g. at (0,0)), even if I try to drag the handle attached with the <span>
'.sidecar2' (black one), it always moves the slider with red <span>
attached to it. The reason behind that is, it is the first handle in the code, between two.
I have tried everything I could, to fix it. E.g. Tried to manually add classes ui-state-active ui-state-focus
to the second(BLACK) slider, tried to change z-index, but none of them are working. :(
Any help would be appreciated.
Thank you.
Edit:
The only solution I could find is given here:
I have created 2 sliders on top of each other with one handle in each. It works perfect.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我能找到的唯一解决方案在这里给出:
我创建了 2 个滑块,每个滑块都有一个手柄。它工作完美。
The only solution I could find is given here:
I have created 2 sliders on top of each other with one handle in each. It works perfect.