nbsp;html> <meta> <title>在页面中显示距离2017年中秋节的天数</title> <script> function countdown(title,Intime,pId) { var online=new Date(Intime); //根据参数定义时间对象 var now=new Date(); //定义当前系统时间 var leave=online.getTime()-now.getTime(); //计算时间差 var day=Math.floor(leave/(1000*60*60*24))+1; if (day>1){ pId.innerHTML="<b>----距离"+title+"还有"+day+"天!<br/>" ; //页面显示信息 }else{ if (day==1){ pId.innerHTML="<b>----明天就是"+title+"啦!<br/>" ; //页面显示信息 }else{ if (day==0) { pId.innerHTML = "<b>----今天就是" + title + "呀!<br/>"; //页面显示信息 }else{ pId.innerHTML="<b>----哎呀!"+title+"已经过了!<br/>" ; //页面显示信息 } } } } </script>
|
以上就是利用JavaScript实现在页面中显示距中秋节的天数效果的详细内容,更多请关注php中文网其它相关文章!
Copyright 2014-2024 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号