html输出js变量改变变量的样式如字体、背景、大小。。下面是详细代码
<head><scriptlanguage="javascript"type="text/javascript">varinterval=1000;functionSho...
<head>
<script language="javascript" type="text/javascript">
var interval = 1000;
function ShowCountDown(year,month,day,divname)
{
var now = new Date();
var endDate = new Date(year, month-1, day);
var leftTime=endDate.getTime()-now.getTime();
var leftsecond = parseInt(leftTime/1000);
//var day1=parseInt(leftsecond/(24*60*60*6));
var day1=Math.floor(leftsecond/(60*60*24));
var hour=Math.floor((leftsecond-day1*24*60*60)/3600);
var minute=Math.floor((leftsecond-day1*24*60*60-hour*3600)/60);
var second=Math.floor(leftsecond-day1*24*60*60-hour*3600-minute*60);
var cc = document.getElementById(divname);
cc.innerHTML = "距离活动结束还有:"+day1
+"天"+hour+"小时"+minute+"分"+second+"秒";
}
window.setInterval(function(){ShowCountDown(2014,2,27,'divdown1');}, interval);
</script>
</head>
<body>
<div id="divdown1" class="divbox">
</div>
</body>
要输出day1这个变量怎么改变他的字体字号 展开
<script language="javascript" type="text/javascript">
var interval = 1000;
function ShowCountDown(year,month,day,divname)
{
var now = new Date();
var endDate = new Date(year, month-1, day);
var leftTime=endDate.getTime()-now.getTime();
var leftsecond = parseInt(leftTime/1000);
//var day1=parseInt(leftsecond/(24*60*60*6));
var day1=Math.floor(leftsecond/(60*60*24));
var hour=Math.floor((leftsecond-day1*24*60*60)/3600);
var minute=Math.floor((leftsecond-day1*24*60*60-hour*3600)/60);
var second=Math.floor(leftsecond-day1*24*60*60-hour*3600-minute*60);
var cc = document.getElementById(divname);
cc.innerHTML = "距离活动结束还有:"+day1
+"天"+hour+"小时"+minute+"分"+second+"秒";
}
window.setInterval(function(){ShowCountDown(2014,2,27,'divdown1');}, interval);
</script>
</head>
<body>
<div id="divdown1" class="divbox">
</div>
</body>
要输出day1这个变量怎么改变他的字体字号 展开
1个回答
2014-02-26
展开全部
cc.innerHTML = "距离活动结束还有:<span style='font-size:30px;'>"+day1
+"</span>天"+hour+"小时"+minute+"分"+second+"秒";
+"</span>天"+hour+"小时"+minute+"分"+second+"秒";
更多追问追答
追问
可以单独加在变量上面吗:cc.innerHTML = "距离活动结束还有:"+day1+"天"+hour+"小时"+minute+"分"+second+"秒";
追答
你的语法有问题,cc.innerHTML = "距离活动结束还有:"+""+day1+""+"天"+hour+"小时"+minute+"分"+second+"秒";
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询