var jumping = false; //hqCode $("#hqCode").on('click',function(){ if (jumping) return false; jumping = true; $(this).addClass("spanGrey").text("60s"); jump(60); getSmscaptcha(); }); function jump(count) { window.setTimeout(function(){ count--; if(count >= 0) { $('#hqCode').text(count+'s'); jump(count); } else { $('#hqCode').removeClass("spanGrey").text("获取验证码"); jumping = false; } }, 1000); }