[Solved] JS condition change class


You need just innerHTML/innerText method and set of conditions. No jQuery needed.

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;

http://jsfiddle.net/hyuu5w5z/

1

solved JS condition change class