Is it possible to use js to change css? What I’m trying to do is pretty simple, I have a timer with a start and a stop button, and would like to set certain intervals where the css will automatically change the background-color css property. For example at 60 seconds change to one green, at 120 seconds change to orange, etc…
Here’s my existing code.
<html>
<head>
<script type=“text/javascript”>
var c=0;
var t;
var timer_is_on=0;
function timedCount()
{
document.getElementById(‘txt’).value=c;
c=c+1;
t=setTimeout(“timedCount()”,1000);
}
function doTimer()
{
if (!timer_is_on)
{
timer_is_on=1;
timedCount();
}
}
function stopCount()
{
clearTimeout(t);
timer_is_on=0;
}
</script><script type=“text/javascript”>
function resizeWindow()
{
top.resizeTo(500,300);
}
</script>
<style type=“text/css”>
body {background-color: RGB(100,100,222);}
</style>
</head>
<body>
<form>
<input type=“button” value=“Start count!” onclick=“doTimer()” />
<input type=“text” id=“txt” />
<input type=“button” value=“Stop count!” onclick=“stopCount()” />
</form>
</body>
</html>