I am currently developing an app and I'm in the process of creating a function that gradually changes the color from black to red based on a numerical value. For instance, if a user selects a number ranging from 0 to 100, they can click a button up to 100 times until they reach a point where clicking is no longer allowed. As they progress, I want the color to transition from black to full red.
Color Progression: Number 0 = black -> Number 100 = full red
Below is the function for incrementing a number onclick:
<input type="text" id="inc" value="0" readonly="readonly"></input>
i = 0; // Default value shown on counter
x = 0; // Maximum value set by the user
function adicionar()
{
if( i < x)
{
i++;
document.getElementById('inc').value = i;
}
}
This is my attempted code logic:
a = x * 50 / 100
b = x * 80 / 100
c = x * 100 / 100
if(i == a){
var $$ = Dom7;
$$('body').addClass('yellow');
}
if(i == b){
var $$ = Dom7;
$$('body').addClass('red');
}
if(i == c){
var $$ = Dom7;
$$('body').addClass('red2');
}
Thank you for your assistance!