After watching a presentation by Lea Verou on CSS Variables titled CSS Variables: var(--subtitle);, I was inspired to create a gradient effect between jQuery Slider handles:
$(function() {
var max = 400;
var $slider = $('.slider');
function set(a, b) {
$slider[0].style.setProperty("--from", (a / max) * 100);
$slider[0].style.setProperty("--to", (b / max) * 100);
}
set(100, 200);
$slider.slider({
values: [100, 200],
min: 0,
max: max,
slide: function(event, ui) {
set.apply(null, ui.values);
}
});
});
.slider {
background: linear-gradient(to right, blue calc(var(--from) * 1%), transparent 0, transparent 0) !important;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="http://code.jquery.com/ui/1.12.0/jquery-ui.min.js"></script>
<link rel="stylesheet" href="http://code.jquery.com/ui/1.12.0/themes/smoothness/jquery-ui.css"/>
<div class="slider"></div>