Да, с JQuery UI оказывается можно настроить подобным образом слайдер.
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>jQuery UI Slider - Range slider</title>
<link rel="stylesheet" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css">
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
<script>
$(function() {
function findNearest(includeLeft, includeRight, value, values) {
var nearest = null;
var diff = null;
for (var i = 0; i < values.length; i++) {
if ((includeLeft && values[i] <= value) || (includeRight && values[i] >= value)) {
var newDiff = Math.abs(value - values[i]);
if (diff == null || newDiff < diff) {
nearest = values[i];
diff = newDiff;
}
}
}
return nearest;
};
function fFireChanging(valueLeft, valueRight){
console.log('valueLeft: ' + valueLeft);
console.log('valueRight: ' + valueRight);
};
$(document).ready(function() {
console.log('filter-script start');
var values = [0, 50, 110, 115, 135, 145, 185, 210, 240, 265, 285, 315, 375, 395, 415, 425, 455, 500];
var iInitValueLeft = 0;
var iInitValueRight = 500;
var slider = $( "#slider-range" ).slider({
range: true,
min: 0,
max: 500,
values: [0, 500],
slide: function( event, ui ) {
var includeLeft = event.keyCode != $.ui.keyCode.RIGHT;
var includeRight = event.keyCode != $.ui.keyCode.LEFT;
var value = findNearest(includeLeft, includeRight, ui.value, values);
if (ui.value == ui.values[0]) {
slider.slider('values', 0, value);
ui.values[ 0 ] = value;
}
else {
ui.values[ 1 ] = value;
slider.slider('values', 1, value);
}
$( "#amount" ).val( "$" + ui.values[ 0 ] + " - $" + ui.values[ 1 ] );
},
change: function(event, ui) {
var includeLeft = event.keyCode != $.ui.keyCode.RIGHT;
var includeRight = event.keyCode != $.ui.keyCode.LEFT;
var value = findNearest(includeLeft, includeRight, ui.value, values);
if (ui.value == ui.values[0] && value != iInitValueLeft) {
iInitValueLeft = value;
fFireChanging(iInitValueLeft, iInitValueRight)
} else if (ui.value == ui.values[1] && value != iInitValueRight) {
iInitValueRight = value;
fFireChanging(iInitValueLeft, iInitValueRight)
};
}
});
slider.slider();
$( "#amount" ).val( "$" + $( "#slider-range" ).slider( "values", 0 ) +
" - $" + $( "#slider-range" ).slider( "values", 1 ) );
});
});
</script>
</head>
<body>
<p>
<label for="amount">Price range:</label>
<input type="text" id="amount" style="border:0; color:#f6931f; font-weight:bold;">
</p>
<div id="slider-range"></div>
</body>
</html>
Решение базируется на скрипте, опубликованном
тут (stackoverflow.com) Только надо ещё продумать как использовать числа с запятой.