I want this HTML button to change the color of my text in order to show/hide it.
div info
is a timer that it’s JavaScript function decreases time. It’s ID in the JavaScript file is gameTime30
.
function changeColor(info) {
const info = document.getElementById(element = 'info');
if (info.style.color == "#333") {
info.style.color = "#EE0000";
} else if (info.style.color == "#EE0000") {
info.style.color = "#333";
}
}
<div id="info">30s</div>
<div id="buttons">
<button id=newGameBtn type="submit" onClick="window.location.reload()">↺</button>
<button id=thirty onClick="changeColor('info')">30s</button>
</div>