As shown below:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><meta charset="utf-8"><head><script src="jquery-2.1.4.min.js" type="text/javascript"></script><script type="text/javascript">var InterValObj; //timer variable, control time var count = 120; //interval function, execute var curCount in 1 second;//current remaining seconds function sendMessage() { curCount = count; //Set button effect, start time $("#btnSendCode").attr("disabled", "true"); $("#btnSendCode").val("Please enter the verification code in " + curCount + "Input verification code in seconds"); InterValObj = window.setInterval(SetRemainTime, 1000); //Start the timer, execute once in 1 second//Send processing data $.ajax({ type: "POST", //Transfer dataType in POST mode: "text", //Data format: JSON url: 'Login.ashx', //Target address data: "dealType=" + dealType +"&uid=" + uid + "&code=" + code, error: function (XMLHttpRequest, textStatus, errorThrown) { }, success: function (msg){ } });}//timer processing function function SetRemainTime() { if (curCount == 0) { window.clearInterval(InterValObj);//Stop timer $("#btnSendCode").removeAttr("disabled");//Enable button $("#btnSendCode").val("Resend verification code"); } else { curCount--; $("#btnSendCode").val("Please enter verification code in" + curCount + "Input verification code in seconds"); } } }</script></head><body> <input id="btnSendCode" type="button" value="Send verification code" onclick="sendMessage()" /></p></body></html>The simple way to implement the above JS SMS countdown is all the content I share with you. I hope you can give you a reference and I hope you can support Wulin.com more.