Reputation: 15
I know this is pretty much stupid for most of you, but I can't get it to work; I need to add classes based on conditions.
Code:
<script>
if (history.score <= 6,0)
{
$('.notabox').addClass('vermelho');
}
else if (history.score <= 8,9)
{
$('.notabox').addClass('laranja');
}
else
{
$('.notabox').addClass('verde');
}
</script>
Upvotes: 0
Views: 68
Reputation: 638
Try this updated code
if (history.score <= 6.0)
{
$('.notabox').addClass('vermelho');
}
else if (history.score <= 8.9)
{
$('.notabox').addClass('laranja');
}
else
{
$('.notabox').addClass('verde');
}
Don't use comma(,) for the decimal point ( i.e : 6,0 and 8,9 updated with decimal point 6.0 and 8.9)
Upvotes: 0
Reputation: 324620
Converting @minitech's comment to answer :p
Your code doesn't work because the decimal point is always .
, not ,
like in some European systems.
That said, judging by your numbers, you could probably do this:
if (history.score <= 6)
$('.notabox').addClass('vermelho');
else if (history.score < 9)
$('.notabox').addClass('laranja');
else
$('.notabox').addClass('verde');
Upvotes: 2