源码网商城,靠谱的源码在线交易网站 我的订单 购物车 帮助

源码网商城

5秒后跳转效果(setInterval/SetTimeOut)

  • 时间:2020-03-11 10:00 编辑: 来源: 阅读:
  • 扫一扫,手机访问
摘要:5秒后跳转效果(setInterval/SetTimeOut)
[b]setInterval版[/b]
[u]复制代码[/u] 代码如下:
$(function () { setInterval(function () { var time = $("#time").text(); time = parseInt(time); time--; if (time >0) { $("#time").text(time); } else { window.location = $("#url").attr("href"); } }, 1000); });
[b]SetTimeOut版[/b]
[u]复制代码[/u] 代码如下:
<script type="text/javascript"> window.onload = function () { setTimeout(changeTime, 1000); } function changeTime() { var time = document.getElementById("time").innerHTML; time = parseInt(time); time--; if (time <= 0) { var url = document.getElementById("url").href; window.location = url; } else { document.getElementById("time").innerHTML= time; setTimeout(changeTime, 1000); } } </script>
html
[u]复制代码[/u] 代码如下:
<span style="font-size: 18px; color: Red" id="time">5</span>秒钟以后跳转到 <a href="<%=this.url %>"
  • 全部评论(0)
联系客服
客服电话:
400-000-3129
微信版

扫一扫进微信版
返回顶部