jQuery.countdown 倒计时插件的使用

这个插件真的挺好用的,虽然好用但是我还是记下来吧,好多插件,今天修改项目的时候看见他居然懵逼

 

官网地址    http://hilios.github.io/jQuery.countdown/

 

 

时间的格式有三种 这些事官网上介绍的

 

 

第一个例子 

一个页面多个倒计时  

<div data-countdown="2017/11/01"></div>
<div data-countdown="2017/11/01"></div>
<div data-countdown="2018/01/01"></div>
<div data-countdown="2019/01/01"></div>
<script src="jquery-1.11.3.min.js"></script>
<script src="jquery.countdown.js"></script>
<script>
$('[data-countdown]').each(function(){
var $this = $(this), finalDate = $(this).data('countdown');
$this.countdown(finalDate, function(event) {
$this.html(event.strftime('%D 天 %H:%M:%S'));
});
})

</script>

2.传统模式的倒计时

<div id="clock"></div>
<script src="jquery-1.11.3.min.js"></script>
<script src="jquery.countdown.js"></script>
<script>
$('#clock').countdown('2017/10/10', function(event) {
var $this = $(this).html(event.strftime(''
+ '<span>%D</span> 天 '
+ '<span>%H</span> 小时 '
+ '<span>%M</span> 分钟 '
+ '<span>%S</span> 秒'));
});
</script>


转载于:https://www.cnblogs.com/dengxiaolei/p/7647951.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
jQuery遮罩层倒计时可以通过使用jQuery插件和Bootstrap来实现。你可以使用Bootstrap的模态框组件来创建遮罩层,并且使用jQuery的计时器功能来实现倒计时。 首先,你需要在页面中引入jQuery和Bootstrap的相关文件。然后,你可以按照下面的步骤来实现遮罩层倒计时: 1. 创建一个按钮或者其他触发事件的元素,当用户点击该元素时,触发倒计时和遮罩层的显示。 2. 使用jQuery的计时器功能来实现倒计时。你可以使用`setInterval`函数来设置一个定时器,每隔一定的时间更新倒计时的显示内容。 3. 在定时器的回调函数中,更新倒计时的显示内容,并根据剩余时间判断是否显示遮罩层。你可以使用jQuery选择器来获取遮罩层的元素,并使用`show`和`hide`函数来控制其显示和隐藏。 4. 当倒计时结束时,你可以触发弹出模态框(遮罩层)的操作。你可以使用`modal`方法来显示模态框。 这是一个简单的实现示例代码: ```html <!DOCTYPE html> <html> <head> <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/css/bootstrap.min.css"> </head> <body> <button id="startCountdown" class="btn btn-primary">开始倒计时</button> <div id="myModal" class="modal fade"> <div class="modal-dialog"> <div class="modal-content"> <div class="modal-header"> <h5 class="modal-title">警告</h5> </div> <div class="modal-body"> <p>您的时间已经用完</p> </div> <div class="modal-footer"> <button type="button" class="btn btn-success" data-dismiss="modal">确定</button> </div> </div> </div> </div> <script src="https://code.jquery.com/jquery-3.5.1.min.js"></script> <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/js/bootstrap.min.js"></script> <script> $(document).ready(function() { $("#startCountdown").click(function() { var countdown = 10; // 设置倒计时的秒数 var countdownTimer = setInterval(function() { countdown--; if (countdown <= 0) { clearInterval(countdownTimer); $("#myModal").modal("show"); // 显示模态框 } else { $("#countdownDisplay").text(countdown); // 更新倒计时显示 } }, 1000); }); }); </script> </body> </html> ```
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值