jquery ,页面倒计时
function get_countdown(elementName) { var t = 59;//倒计总秒数 var time = 59;//当前秒数 if (time == t) { //如果不加入该判断,则会出现在倒计时期间不断的点击发生不断的加快(其实就是你点了多少次就重复多少次该函数)的问题,用setTimeout()方法不加此判断也是一样的 var time1 = setInterval(function() { if (time == 0) { $(elementName).html("Resend"); $(elementName).removeAttr("disabled"); time = t; clearInterval(time1); $(elementName).addClass("bg-color4").removeClass("bg-color3"); } else { $(elementName).attr("disabled","true"); $(elementName).html(time + "s Resend"); $(elementName).removeClass("bg-color4").addClass("bg-color3"); time--; } console.log(time); }, 1000); } }
相关推荐
Greatemperor 2020-07-19
勇往直前 2020-05-17
igogo00 2020-05-15
CloudXli 2020-02-21
GoatSucker 2020-02-09
千锋 2020-01-29
assastor 2020-01-29
llwang0 2019-12-28
azhou 2019-12-27
Airuio 2019-12-20
sunnyJam 2019-12-08
wyqwilliam 2019-11-12
Laozizuiku 2019-11-12
zhangpan 2019-11-10
sprintwind 2011-03-23
xianhe0 2010-08-25
Python探路者 2019-06-18