- html部份
<input type="button" class="gainCodeBtn" value="馬上獵取" onclick="settime(this)" />
- css部份
.gainCodeBtn{
background-color: #ff4646;
color: #ffffff;
border: none;
font-size: 1rem;
letter-spacing: 0.1rem;
height: 1.8rem;
line-height: 1.8rem;
border-radius: 0.6rem;
}
input[type="button" i]:disabled, input[type="submit" i]:disabled, input[type="reset" i]:disabled, input[type="file" i]:disabled::-webkit-file-upload-button, button:disabled, select:disabled, optgroup:disabled, option:disabled, select[disabled] > option {
color: graytext;
}
input:disabled, textarea:disabled {
cursor: default;
background-color:#cecece;
}
input[type="button" i], input[type="submit" i], input[type="reset" i] {
-webkit-appearance: push-button;
user-select: none;
white-space: pre;
}
input, textarea, select, button, meter, progress {
-webkit-writing-mode: horizontal-tb !important;
}
js部份
- 注重此處要自行引入jquery
<!--發送驗證碼-->
<script>
//倒計時
var countdown=60;
function settime(val) {
if (countdown == 0) {
val.removeAttribute("disabled");
val.value="馬上獵取";
countdown = 60;
return false;
} else {
val.setAttribute("disabled", true);
val.value="還剩" + countdown + "s";
countdown--;
}
setTimeout(function() {
settime(val);
},1000);
}
</script>
宣佈於瀏覽原博:https://blog.csdn.net/hj7jay/… 以後,補充了css部份代碼,輕易下次己用,供小白參考(侵刪~)