If you're looking to create a custom range slider with jQuery UI, you can easily do so by implementing the following code snippet.
$.fn.addRange = function (min, max) {
this.prepend('<div class=range></div>');
$range = this.find('.range');
$range.css("left", min * 100 + '%');
$range.css("right", 100 - (max * 100) + '%');
};
var $slider = $('#slider');
$slider.slider();
$slider.addRange(0.2, 0.4);
This script will insert a
<div class=range></div>
element inside the slider and adjust its positioning based on the specified minimum and maximum values.
Furthermore, here is the accompanying CSS styling for the slider and range elements:
#slider {
background-color: red;
background-image: none;
}
.range {
position: absolute;
top: 0;
bottom: 0;
background-color: green;
}
For a visual demonstration of the result, you can view the live demo using this link: http://jsbin.com/eheden/1/edit