jeudi 7 avril 2016

Last else if statement not working

I'm trying to create a simple if statement to change the background colour of a div depending on the number entered within another div. I've tried making a few changes to the code but can never get the last else if statement to work.

if ($(".pacenumber").text() <= "59") {
document.getElementById("paceheader").style.backgroundColor = "red";
} 
else
if ($(".pacenumber").text() >= "60" < "80") {
document.getElementById("paceheader").style.backgroundColor = "yellow";
}
else
if ($(".pacenumber").text() >= "80") {
document.getElementById("paceheader").style.backgroundColor = "green";
}

If the number entered is <= "59" the div changes to red correctly.

If the number entered is >= "60" and < "80" the div changes to yellow correctly.

If the number entered is >= "80" the div stays yellow and will not change to green.

Is there a possible solution to get the last if statement working?

Aucun commentaire:

Enregistrer un commentaire