您应该使用幻灯片功能并强制执行
$(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.net/nicolapeluchetti/kGtsN/17/
从文档
滑动
在滑动期间每次鼠标移动都会触发此事件。使用 ui.value(单柄滑块)获取当前句柄的值,$(..).slider('value', index) 获取另一个句柄的值。
根据 ui.value 返回 false 以防止滑动。