javascript - 如何使用 Cookie 防止刷新倒数计时器以及如何在计时器到达 0 时显示消息
问题描述
如何使用 Cookie 防止刷新倒数计时器以及如何在计时器到达 0 时显示消息
var secondsBeforeExpire = 5;
// This will trigger your timer to begin
var timer = setInterval(function(){
// If the timer has expired, disable your button and stop the timer
if(secondsBeforeExpire <= 0){
clearInterval(timer);
$("#buynowofferone").prop('disabled',true)
document.getElementById("nextoffer").innerHTML = " SHOW ME NEXT OFFER"
$("#time-remaining").hide()
document.getElementById("smile").innerHTML = "OFFER EXPIRED ☹";
}
// Otherwise the timer should tick and display the results
else{
// Decrement your time remaining
secondsBeforeExpire--;
$("#time-remaining").text( " Expires in " + secondsBeforeExpire + " Seconds ⚠") ;
}
},1000);
解决方案
推荐阅读
- aws-amplify - AWS - Amplify - 有没有办法从前端使用放大来更改或更新用户的电子邮件?
- rest - 从 BitBucket Rest API v2.0 获取文件
- sqlite - SQL查询:如何计算列中特定值的出现而不对该列进行分组?
- c - Microsoft Visual C++ 运行时检查失败 #2
- java - Java - 使用单独的方法计算随机生成器方法中字符的出现次数
- java - Jersey 删除 - id 包含斜杠 - URLEncode 不起作用
- spring-boot - Spring Boot 无法将 Redis 客户端 Jedis 连接到池:连接被拒绝
- javascript - 如何在 2D 空间 (x,y) 中制作 3D (X,Y,Z) 形状
- azure - 我可以在 BotBuilder 中使用 PubNub 而不是 DirectLine 吗?
- powershell - Powershell - 命令文本未出现