[{"createTime":1735734952000,"id":1,"img":"hwy_ms_500_252.jpeg","link":"https://activity.huaweicloud.com/cps.html?fromacct=261f35b6-af54-4511-a2ca-910fa15905d1&utm_source=V1g3MDY4NTY=&utm_medium=cps&utm_campaign=201905","name":"华为云秒杀","status":9,"txt":"华为云38元秒杀","type":1,"updateTime":1735747411000,"userId":3},{"createTime":1736173885000,"id":2,"img":"txy_480_300.png","link":"https://cloud.tencent.com/act/cps/redirect?redirect=1077&cps_key=edb15096bfff75effaaa8c8bb66138bd&from=console","name":"腾讯云秒杀","status":9,"txt":"腾讯云限量秒杀","type":1,"updateTime":1736173885000,"userId":3},{"createTime":1736177492000,"id":3,"img":"aly_251_140.png","link":"https://www.aliyun.com/minisite/goods?userCode=pwp8kmv3","memo":"","name":"阿里云","status":9,"txt":"阿里云2折起","type":1,"updateTime":1736177492000,"userId":3},{"createTime":1735660800000,"id":4,"img":"vultr_560_300.png","link":"https://www.vultr.com/?ref=9603742-8H","name":"Vultr","status":9,"txt":"Vultr送$100","type":1,"updateTime":1735660800000,"userId":3},{"createTime":1735660800000,"id":5,"img":"jdy_663_320.jpg","link":"https://3.cn/2ay1-e5t","name":"京东云","status":9,"txt":"京东云特惠专区","type":1,"updateTime":1735660800000,"userId":3},{"createTime":1735660800000,"id":6,"img":"new_ads.png","link":"https://www.iodraw.com/ads","name":"发布广告","status":9,"txt":"发布广告","type":1,"updateTime":1735660800000,"userId":3},{"createTime":1735660800000,"id":7,"img":"yun_910_50.png","link":"https://activity.huaweicloud.com/discount_area_v5/index.html?fromacct=261f35b6-af54-4511-a2ca-910fa15905d1&utm_source=aXhpYW95YW5nOA===&utm_medium=cps&utm_campaign=201905","name":"底部","status":9,"txt":"高性能云服务器2折起","type":2,"updateTime":1735660800000,"userId":3}]
JavaScript网页–跨年倒计时,供大家参考,具体内容如下
最近学弟在追一个学妹,我在帮学弟出谋划策。
学妹告诉学弟,我怕我们之间是因为这段时间接触多了你才喜欢我的。等跨年的时候,如果你还喜欢我,那个时候我再给你答案。
于是今天我帮学弟做了一个跨年倒计时的网页,希望他能够坚持下去。
倒计时
div {
margin-top: 200px;
margin-left: 500px;
line-height: 50px;
font-size: 20px;
font-weight: 900;
}
li {
float: left;
margin: 2px;
list-style: none;
width: 50px;
height: 50px;
color:white;
line-height: 50px;
text-align: center;
background-color: black;
font-size: 20px;
font-weight: 900;
}
跨年倒计时:0123
//获取元素
var day = document.querySelector('.day');
var hour = document.querySelector('.hour');//获取小时元素
var minute = document.querySelector('.minute');//获取分钟元素
var second = document.querySelector('.second');//获取秒数元素
var inputTime = +new Date('2021-1-1 00:00:00');//输入一个时间
countDown ();//在定时器开启之前先调用一次函数,防止一秒的空白期
//开启定时器
setInterval(countDown, 1000);
function countDown (){
//获取当前的时间
var nowTime = +new Date();
var times = (inputTime - nowTime) / 1000;//times是剩余的总秒数
var d = parseInt(times / 60 / 60 /24);
d = d < 10 ? '0'+ d : d;
//将剩余的小时数给小时的盒子
day.innerHTML = d+"天";
//小时
var h = parseInt(times / 60 / 60 % 24);
h = h < 10 ? '0'+ h : h;
//将剩余的小时数给小时的盒子
hour.innerHTML = h+"时";
// 分钟
var m = parseInt(times / 60 % 60);
m = m < 10 ? '0'+ m : m;
//将剩余的分钟数给分钟的盒子
minute.innerHTML = m+"分";
//秒数
var s = parseInt(times % 60);
s = s < 10 ? '0'+ s : s;
//将剩余的描述给秒的盒子
second.innerHTML = s+"秒";
}
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持脚本之家。