I'm not 100% sure if my JavaScript is correct, however it is showing 'Testing' even though I have 'FEW' as a text value - it should pick this up and bar = "Medium", however it didn't.
if (document.getElementById('raw').innerHTML.indexOf("CLR") != -1) {
bar = "Excellent";
} else if (document.getElementById('raw').innerHTML.indexOf("FEW") != -1) {
bar = "Medium";
} else {
bar = "Testing";
}
document.getElementById("bar").innerHTML = bar;
The HTML:
<p>Live: </p><div class="d-none" id="raw"></div>
<div class="d-none">
<h5>Test: <span id="bar"></span>.</h5></div>
Aucun commentaire:
Enregistrer un commentaire