JSFiddle - React, Tailwind, and code Playground
HTML
<div id="polIndice" class="indice">32</div>
CSS
.indiceLow {color: green;}
.indiceMedium {color: yellow;}
.indiceHigh {color: red;}
JavaScript
var el = document.getElementById('polIndice');
var val = parseInt(el.innerText);
var class_name;
if (val < 50) {
class_name = 'indiceLow';
} else if (val < 100) {
class_name = 'indiceMedium';
} else {
class_name = 'indiceHigh';
}
el.className += ' ' + class_name;