I just want to change the font color of my timer to white so it could go well with my preferred background color.
Here's my fiddle. https://jsfiddle.net/fpouew9d/.
var CCOUNT = 30; var t, count; function cddisplay() { // displays time in span document.getElementById('timespan').innerHTML = count; }; function countdown() { // starts countdown cddisplay(); if (count == 0) { // time is up } else { count--; t = setTimeout("countdown()", 1000); } }; function cdpause() { // pauses countdown clearTimeout(t); }; function cdreset() { // resets countdown cdpause(); count = CCOUNT; cddisplay(); }; cdreset()
p { color: white; } body { background-color: #242424; }
<p> Some text </p> <span id="timespan"></span> <input type="button" value="Start" onclick="countdown()"> <input type="button" value="Stop" onclick="cdpause()"> <input type="button" value="Reset" onclick="cdreset()">
First, you have setInterval function. You can use it instead of hacks around setTimeout.
setInterval
setTimeout
To change color of any text in css:
#timespan { color: white; }
1.4m articles
1.4m replys
5 comments
56.9k users