I created a counter but I want to change the color of the id="clicks" based on whether the value is positive or negative, and also add text accordingly.
var clicks = 0;
function clickplus() {
clicks += 1;
document.getElementById("clicks").innerHTML = clicks;
}
var clicks = 0;
function clickless() {
clicks -= 1;
document.getElementById("clicks").innerHTML = clicks;
}
#btn_plus{
background-color: #04AA6D; /* Green */
border: none;
color: white;
padding: 15px 32px;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 16px;}
#btn_less{
background-color: red; /* Green */
border: none;
color: white;
padding: 15px 32px;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 16px;}
<body style="background-color:#F0F0F0">
<center>
</br></br></br>
<h1>
<p style="color:#002244">COUNT: <a id="clicks">0</a></p>
</h1>
<button id="btn_plus" type="button" onClick="clickplus()">+1</button>
<button id="btn_less" type="button" onClick="clickless()">-1</button>
</center>
</body>
Is there anyone who can assist? Change the color of id="clicks" to red if the value is negative, green if it's positive, and display the text positive/negative accordingly.