在线等~如何将JS计算结果输出到页面?
<body><script>Date.prototype.diff=function(date){return(this.getTime()-date.getTime()...
<body>
<script>
Date.prototype.diff = function(date){
return (this.getTime() - date.getTime())/(24 * 60 * 60 * 1000);
}
var now = new Date('2015/02/19 00:00:00');
var date = new Date();
var diff = now.diff(date);
document.getElementById('end2').innerHTML = math.floor(diff);
</script>
距过年<span id="end2"></span>天
</body>
代码如上,<span>就是不显示,求高手看看哪里有错? 展开
<script>
Date.prototype.diff = function(date){
return (this.getTime() - date.getTime())/(24 * 60 * 60 * 1000);
}
var now = new Date('2015/02/19 00:00:00');
var date = new Date();
var diff = now.diff(date);
document.getElementById('end2').innerHTML = math.floor(diff);
</script>
距过年<span id="end2"></span>天
</body>
代码如上,<span>就是不显示,求高手看看哪里有错? 展开
展开全部
将JS计算结果输出到页面的代码如下:
<!DOCTYPE HTML>
<html>
<head>
<meta charset="UTF-8" />
<title>last.html</title>
<style>
</style>
<script type="text/javascript">
Date.prototype.diff = function (date)
{
return (this.getTime () - date.getTime ()) / (24 * 60 * 60 * 1000);
}
onload = function ()
{
var now = new Date ('2015/02/19 00:00:00');
var date = new Date ();
var diff = now.diff (date);
document.getElementById ('end2').innerHTML = Math.floor (diff);
}
</script>
</head>
<body>
距过年
<span id="end2"></span>天
</body>
</html>
展开全部
<!DOCTYPE HTML>
<html>
<head>
<meta charset="UTF-8" />
<title>last.html</title>
<style>
</style>
<script type="text/javascript">
Date.prototype.diff = function (date)
{
return (this.getTime () - date.getTime ()) / (24 * 60 * 60 * 1000);
}
onload = function ()
{
var now = new Date ('2015/02/19 00:00:00');
var date = new Date ();
var diff = now.diff (date);
document.getElementById ('end2').innerHTML = Math.floor (diff);
}
</script>
</head>
<body>
距过年
<span id="end2"></span>天
</body>
</html>
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
Math.floor(diff);
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询