<!doctype html><html><head><meta charset="utf-8"><title>無標題文檔</title></head><body><input class="code" onClick="TestGetCode(this)" value="獲取驗證碼" type="button"/><br><input class="code" onClick="TestGetCode(this)" value="獲取驗證碼" type="button"/><script type="text/javascript" src="js/jquery-1.11.1.min.js"></script><script type="text/javascript">//獲取短信驗證碼var t=60;function TestGetCode(i){ if(t==0){ i.removeClass("grey-bg"); i.removeAttribute("disabled"); i.value="獲取短信驗證碼"; t=60; }else{ i.setAttribute("disabled", true); i.value="重新發送(" + t + ")"; t--; $(this).addClass("grey-bg"); setTimeout(function(){TestGetCode(i)},1000); }}</script></body></html>點擊其中一個還好,兩個都點就出問題了
怎樣讓兩個定時器不互相影響?
慕無忌1623718
2018-08-18 10:09:00