5秒跳转javascript
【代码】5秒跳转javascript。
·
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<p style="text-align: center;"> <span style="color: red;">5</span>秒之后,自动跳转到首页</p>
<script>
var num=5
setInterval(function(){
num--
var span=document.querySelector("span")
span.innerHTML=num
if(num==0){
location.href="https://www.baidu.com/"
}
},1000)
</script>
</body>
</html>
效果
更多推荐
所有评论(0)