JSFiddle - React, Tailwind, and code Playground

by divinemamgai

HTML

<div class="correct_incorrect" >
    Value is shown here!
    You see the correct value is <b>10</b> and incorrect value is <b>9</b>! But still it is showing red color!
</div>

CSS

div.correct_incorrect
{
 padding: 5px 5px;   
 border: 5px solid #567;
 font-family: arial;
 color: #fff;
 font-size: 12px;
}

JavaScript

$(function () {

                      var correct = '10';
                      var incorrect = '9';
                      
                      $('div.correct_incorrect').css("background",function () {
                          
                          if( correct > incorrect )
                          {
                             return "#796";
                          }
                          else if( correct == incorrect )
                          {
                             return "#345";
                          }
                          else
                          {
                             return "#732";
                          }

                      });
                   });