To begin, the first step is to reset the appearance of the input range specifically for webkit and gecko based browsers:
#myRange {
-webkit-appearance: none;
}
#myRange::-moz-range-thumb{
-moz-appearance: none;
}
#myRange::-webkit-slider-thumb {
-webkit-appearance: none;
}
It's important to add additional rules since the appearance of the element is no longer defined (refer to the fiddle below).
Next, listen for cursor movements using the input
event, and dynamically create a CSS rule in a style sheet:
$("#myRange").on("input", function (evt) {
if (evt.target.value > 50)
var rule= "background:red";
else
var rule= "yellow"
sheet.textContent =
"#myRange::-webkit-slider-thumb{ "+rule+" } " +
"#myRange::-ms-thumb{ "+rule+" } " +
"#myRange::-moz-range-thumb{ "+rule+" } ";
})
https://jsfiddle.net/rv9xqwq6/8/
Here are some useful resources:
http://codepen.io/thebabydino/pen/jEXjVE