admin管理员组文章数量:1317915
I'm using a jQuery slider with a fixed minimum of 20, as described in the docs.
However, it's not quite what I need. I'd like the visual range of the slider to be 0-100, but the user should never be allowed to move the slider to less than 20.
In other words, the handle of the slider should never go all the way to the left-hand side of the slider (as it does at the moment), but should show the range 0-20.
Here is a JSFiddle to show what I mean, and here is the current code:
$("#range-slider").slider({
range: "min",
min: 20,
max: 100,
value: 20,
step: 20,
});
Any ideas?
I'm using a jQuery slider with a fixed minimum of 20, as described in the docs.
However, it's not quite what I need. I'd like the visual range of the slider to be 0-100, but the user should never be allowed to move the slider to less than 20.
In other words, the handle of the slider should never go all the way to the left-hand side of the slider (as it does at the moment), but should show the range 0-20.
Here is a JSFiddle to show what I mean, and here is the current code:
$("#range-slider").slider({
range: "min",
min: 20,
max: 100,
value: 20,
step: 20,
});
Any ideas?
Share Improve this question asked Jul 18, 2012 at 16:20 flossfanflossfan 10.9k16 gold badges45 silver badges54 bronze badges1 Answer
Reset to default 8You should use the slide function and enforce that
$(document).ready(function() {
// I want the visual range to be 0-100,
// but the minimum allowed value to be 20 -
// so in other words, the handle never gets
// all the way to the LHS of the slider,
// but shows the range 0-20.
// Is this possible?
$("#range-slider").slider({
range: "min",
min: 0,
max: 100,
value: 20,
step: 20,
slide: function(event, ui) {
if (ui.value < 20) {
return false;
}
}
});
});
http://jsfiddle/nicolapeluchetti/kGtsN/17/
From the docs
Slide
This event is triggered on every mouse move during slide. Use ui.value (single-handled sliders) to obtain the value of the current handle, $(..).slider('value', index) to get another handles' value.
Return false in order to prevent a slide, based on ui.value.
本文标签:
版权声明:本文标题:javascript - jQuery UI Slider with fixed minimum: show minimum range, not minimum absolute value? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742020994a2414669.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论