Js如何用函数声明字体颜色 网页上显示一个时钟,怎样使“时、分、秒”的颜色显示为红色?
我的代码如下:<html><head><styletype="text/css">div.top{width:210px;padding:5px;margin:0px;b...
我的代码如下:
<html>
<head>
<style type="text/css">
div.top
{
width:210px; padding:5px; margin:0px; border:1px solid red;
}
</style>
<script type="text/javascript">
function showTime()
{
var today=new Date();
var y=today.getYear();
var month=today.getMonth()+1;
var d=today.getDate();
var h=today.getHours();
var m=today.getMinutes();
var s=today.getSeconds();
var day=today.getDay();
var Day=new Array(7);
Day[0]="星期日"
Day[1]="星期一"
Day[2]="星期二"
Day[3]="星期三"
Day[4]="星期四"
Day[5]="星期五"
Day[6]="星期六"
h=checkTime(h);
m=checkTime(m);
s=checkTime(s);
document.getElementById('time').innerHTML=y+"年"+month+"月"+d+"日 "+h+":"+m+":"+s+" "+Day[day];
t=setTimeout('showTime()',1000);
}
function checkTime(i)
{
if (i<10)
{i="0" + i}
return i
}
</script>
</head>
<body onload="showTime()">
<div class="top" id="time"></div>
</body>
</html>
请大能帮忙解决 谢谢 展开
<html>
<head>
<style type="text/css">
div.top
{
width:210px; padding:5px; margin:0px; border:1px solid red;
}
</style>
<script type="text/javascript">
function showTime()
{
var today=new Date();
var y=today.getYear();
var month=today.getMonth()+1;
var d=today.getDate();
var h=today.getHours();
var m=today.getMinutes();
var s=today.getSeconds();
var day=today.getDay();
var Day=new Array(7);
Day[0]="星期日"
Day[1]="星期一"
Day[2]="星期二"
Day[3]="星期三"
Day[4]="星期四"
Day[5]="星期五"
Day[6]="星期六"
h=checkTime(h);
m=checkTime(m);
s=checkTime(s);
document.getElementById('time').innerHTML=y+"年"+month+"月"+d+"日 "+h+":"+m+":"+s+" "+Day[day];
t=setTimeout('showTime()',1000);
}
function checkTime(i)
{
if (i<10)
{i="0" + i}
return i
}
</script>
</head>
<body onload="showTime()">
<div class="top" id="time"></div>
</body>
</html>
请大能帮忙解决 谢谢 展开
1个回答
展开全部
<html>
<head>
<style type="text/css">
div.top
{
width:210px; padding:5px; margin:0px; border:1px solid red;
}
</style>
<script type="text/javascript">
function showTime()
{
var today=new Date();
var y=today.getFullYear();
var month=today.getMonth()+1;
var d=today.getDate();
var h=today.getHours();
var m=today.getMinutes();
var s=today.getSeconds();
var day=today.getDay();
var weekday=new Array(7);
weekday[0]="星期日"
weekday[1]="星期一"
weekday[2]="星期二"
weekday[3]="星期三"
weekday[4]="星期四"
weekday[5]="星期五"
weekday[6]="星期六"
h=checkTime(h);
m=checkTime(m);
s=checkTime(s);
document.getElementById('time').innerHTML="<span style='color:blue'>"+y+"年"+month+"月"+d+"日</span>"+"<span style='color:red'> "+h+":"+m+":"+s+"</span>"+"<span style='color:green'> "+weekday[day]+"</span>";
t=setTimeout('showTime()',1000);}
function checkTime(i)
{
if (i<10)
{i="0" + i}
return i
}
</script>
</head>
<body onload="showTime()">
<div class="top" id="time"></div>
</body>显示系统当前时间代码
</html>
<head>
<style type="text/css">
div.top
{
width:210px; padding:5px; margin:0px; border:1px solid red;
}
</style>
<script type="text/javascript">
function showTime()
{
var today=new Date();
var y=today.getFullYear();
var month=today.getMonth()+1;
var d=today.getDate();
var h=today.getHours();
var m=today.getMinutes();
var s=today.getSeconds();
var day=today.getDay();
var weekday=new Array(7);
weekday[0]="星期日"
weekday[1]="星期一"
weekday[2]="星期二"
weekday[3]="星期三"
weekday[4]="星期四"
weekday[5]="星期五"
weekday[6]="星期六"
h=checkTime(h);
m=checkTime(m);
s=checkTime(s);
document.getElementById('time').innerHTML="<span style='color:blue'>"+y+"年"+month+"月"+d+"日</span>"+"<span style='color:red'> "+h+":"+m+":"+s+"</span>"+"<span style='color:green'> "+weekday[day]+"</span>";
t=setTimeout('showTime()',1000);}
function checkTime(i)
{
if (i<10)
{i="0" + i}
return i
}
</script>
</head>
<body onload="showTime()">
<div class="top" id="time"></div>
</body>显示系统当前时间代码
</html>
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询