1效果图
![在这里插入图片描述](https://i-blog.csdnimg.cn/blog_migrate/4f86f58cf835ff10e24d5ea4fb1edaa2.png#pic_center)
代码
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
input {
width: 300px;
}
</style>
</head>
<body>
<div class="box">
距离:<input type="text">
<br> 还剩:
<input type="text">
</div>
<button class="btn">开始倒计时吧</button>
<script>
var ipt = document.querySelectorAll(".box input")
var btn = document.querySelector(".btn")
btn.onclick = function() {
var a = ipt[0].value
setInterval(function() {
this.clearInterval();
var date = new Date();
var HT = date.getTime()
var date1 = new Date(a);
var GT = date1.getTime()
var dao = GT - HT
ipt[1].value = parseInt(dao / 1000 / 60 / 60 / 24) + "天" + parseInt(dao / 1000 / 60 / 60 % 24) + "小时" + parseInt(dao / 1000 / 60 % 60) + "分" + parseInt(dao / 1000 % 60) + "秒"
}, 1000)
}
</script>
</body>
</html>