<script>
function countDown(maxtime, fn) {
var timer = setInterval(function () {
if (maxtime > 0) {
var minutes = Math.floor((maxtime % 3600) / 60),
seconds = Math.floor(maxtime % 60),
msg = minutes + "分" + seconds + "秒";
fn(msg);
--maxtime;
}
else if (maxtime <= 0) {
var minutes = Math.floor((maxtime % 3600) / 60),
seconds = Math.floor(maxtime % 60),
msg = minutes + "分" + seconds + "秒";
fn(msg);
--maxtime;
}
}, 1000);
}
var Time = [5, 121, 516, 156, 891, 198, 813, 511, 259, 516, 125, 813, 951, 489, 159, 223];
for (var i = 0; i < 16; i++) {
(function (i) {
var obj = 'timer' + i;
countDown
(Time[i], function (msg) {
document.getElementById(obj).innerHTML = msg;
document.getElementById(obj).style.cssText = "color:green;color:red;"
})
})(i)
}
script>
问一下怎么让字体颜色根据正负数显示绿红
你这里面也没有负数啊