I want this HTML button to change the color of my text in order to show/hide it.
My current code:
<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>
<script>
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";
}
}
</script>
div ‘info’ is a timer that it’s JavaScript function decreases time. It’s ID in the JavaScript file is ‘gameTime30’.
You need to sign in to view this answers