Skip to content

Instantly share code, notes, and snippets.

@lichenbuliren
Last active September 13, 2016 09:14
Show Gist options
  • Save lichenbuliren/d612cecd1cf7db00d63bae23a1596514 to your computer and use it in GitHub Desktop.
Save lichenbuliren/d612cecd1cf7db00d63bae23a1596514 to your computer and use it in GitHub Desktop.
/**
* 倒计时
* @param {[type]} countTime 倒计时时间
* @param {[type]} perFn 每秒执行的函数
* @param {[type]} complate 倒计时完成函数
* @return {[type]} [description]
*/
function countDown(countTime, perFn, complate) {
var count = countTime;
countFn(count);
function countFn(count) {
if (count == 0) {
complate && complate();
return;
} else {
count--;
perFn(count);
setTimeout(function() {
countFn(count);
}, 1000);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment