标签:function return tar main date pre charset blog htm
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title></title> </head> <body> <script src="jquery.js"></script> <script> // 倒计时插件 (function() { function countdown(config) { var startDate = config.start ? new Date(config.start) : new Date(); var endDate1 = new Date(config.end1); var endDate2 = new Date(config.end2); var id = config.id || ‘countdown‘; var time1 = (endDate1 - startDate) / 1000; var time2 = (endDate2 - startDate) / 1000; // 结束后 if (time2 < 0) { if (config.callback) { config.callback(); } return; // end1 与 end2 进行中 } else if (time1 < 0 && time2 > 0) { if (config.callbacking) { config.callbacking(); } time_set(time2); } function time_set(time) { setTimeout(function() { countdown(config); }, 1000); } // end1 前面 if (time1 > 0) { time_set(time1); } } window.countdown = countdown; })(); // 引用倒计时 countdown({ ‘end1‘: ‘2017/01/20 20:39:30‘, ‘end2‘: ‘2017/01/20 24:00:00‘, ‘callbacking‘: function() { $(".main").html("aaabbbcc"); }, ‘callback‘: function() { $(".main").html("aaabbbccdddddd"); } }); </script> <div class="main">你好,世界</div> </body> </html>
时间进行3段区分 执行倒计时 end1 end2 开始执行回调
标签:function return tar main date pre charset blog htm
原文地址:http://www.cnblogs.com/zerohu/p/6327368.html