I Have a slider that has a number output associated with it. I am able to apply the color for all the number, but it doesn't change when the slider value goes to a different color range.
document.body.addEventListener("change", color());
function color() {
if (document.getElementById("strengthLevel").innerHTML < 31) {
document.getElementById("outpu").style.color = "Green";
} else if (document.getElementById("strengthLevel").innerHTML < 55) {
document.getElementById("outpu").style.color = "Yellow";
} else {
document.getElementById("outpu").style.color = "Red";
}
}
<div class="form-group" oninput="outpu.value=strengthLevel.value, color()">
<label for="strengthLevel">Caffeine Rating </label> <label> <output id="outpu">30</output></label>
<input name="strength" id="strengthLevel" type="range" value="30">
</div>
<button type="submit" class="btn btn-default">Submit</button>
<button type="reset" class="btn btn-default">Reset</button>
</form>
</div>
</div>
<div class="panel panel-default">
<div class="panel-body">
<h4>Pending Orders:</h4>
<div data-coffee-order="checklist">
</div>
</div>
</div>
</section>
I tired this code and I am only able to make the text green