jquery實現(xiàn)表單獲取短信驗證碼代碼
更新時間:2017年03月13日 14:49:40 作者:艾米
本文主要分享了jquery實現(xiàn)表單獲取短信驗證碼的代碼。具有很好的參考價值。下面跟著小編一起來看下吧
效果圖:

代碼如下:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>jquery表單獲取短信驗證碼代碼</title>
<script src="http://libs.baidu.com/jquery/2.0.0/jquery.min.js"></script>
<script>
$(function(){
//獲取短信驗證碼
var validCode=true;
$(".msgs").click (function () {
var time=30;
var code=$(this);
if (validCode) {
validCode=false;
code.addClass("msgs1");
var t=setInterval(function () {
time--;
code.html(time+"秒");
if (time==0) {
clearInterval(t);
code.html("重新獲取");
validCode=true;
code.removeClass("msgs1");
}
},1000)
}
})
})
</script>
<style type="text/css">
form{margin:200px auto;width:500px;}
label{font-size:14px;color:#555;line-height:40px;margin-right:10px;}
input{width:212px;height:38px;border-style:none;padding:0 4px;border:1px solid #C8C8C8;margin-right:10px;outline:none;}
.msgs{display:inline-block;width:104px;color:#fff;font-size:12px;border:1px solid #0697DA;text-align:center;height:30px;line-height:30px;background:#0697DA;cursor:pointer;}
form .msgs1{background:#E6E6E6;color:#818080;border:1px solid #CCCCCC;}
</style>
</head>
<body>
<form>
<label>驗 證 碼</label>
<input type="text">
<span class="msgs">獲取短信驗證碼</span>
</form>
</body>
</html>
以上就是本文的全部內(nèi)容,希望本文的內(nèi)容對大家的學習或者工作能帶來一定的幫助,同時也希望多多支持腳本之家!
相關(guān)文章
利用jQuery+localStorage實現(xiàn)一個簡易的計時器示例代碼
這篇文章主要給大家介紹了關(guān)于利用jQuery+localStorage實現(xiàn)一個簡易的計時器的相關(guān)資料,文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友們下面來一起看看吧。2017-12-12
jQuery控制input只能輸入數(shù)字和兩位小數(shù)的方法
這篇文章主要介紹了jQuery控制input只能輸入數(shù)字和兩位小數(shù)的相關(guān)知識,本文給大家介紹的非常詳細,具有一定的參考借鑒價值,需要的朋友可以參考下2019-05-05

