JavaScriptでsetTimeoutを使うサンプルコード
JavaScriptコード:
<input type="button" id="smsauth-btn" class="smsauth-btn" value="認証コード"/>
var t = 120;
showT(t);
function showT(t) {
if(t > 0){
$(“.smsauth-btn").val(t +"秒");
setTimeout(function(){showT(t-1)},1000)
//setTimeout(showT(t-1),5000)
//$('.smsauth-btn’).attr(“disabled",true);
}else{
$(“.smsauth-btn").val(“SMS認証");
//$(“.smsauth-btn").removeAttr(“disabled");
}
}