I'd like to change the color of a noUiSlider connect element when a value condition is met, and I can't figure out how to make JavaScript change the color set in the CSS:
.noUi-connect {
background: green;
}
Minimal example below. How can I replace {console.log("true")} with something that will change the connect color?
<!DOCTYPE html>
<head>
<meta charset="utf-8">
<link href="nouislider.min.css" rel="stylesheet">
<link href="notooltips.css" rel="stylesheet">
</head>
<script src="nouislider.min.js"></script>
<script src="wNumb.js"></script>
<div id="tooltipSlider"><script>
var tooltipSlider = document.getElementById('tooltipSlider');
noUiSlider.create(tooltipSlider, {
start: [1, 9],
connect: true,
tooltips: [true, true],
range: {'min': 0,'max': 10}
});</script>
<script>tooltipSlider.noUiSlider.on("change", function(){
if (tooltipSlider.noUiSlider.get()[0] == 0) {
console.log("true")} {console.log("false")}})</script>
</div></html>
Note both strings log when tooltipSlider.noUiSlider.get()[0] == 0 seems met for reasons I don't understand, so perhaps this if statement is unsuitable. The connect element must be some color when condition is true (or slider is set to that value), another color when false.
There's already an unaccepted answer to a similar question I don't understand. Can this be used?