MIverification

功能描述

依赖的模块

快速使用

  1. <div class="code"> -------------- 一级结构
  2. <div class="code-one"> -------------- 二级结构
  3. <input type="text" value=" 请输入验证码" class="input" id="input" /><button id="bt01" class="verification">验证码</button> -----------三级结构
  4. </div>
  5. <div class="code-one">
  6. <input type="text" value=" 请输入验证码" class="input" id="input_a" /><button id="bt02" class="verification-yellow">获取验证码</button>
  7. </div>
  8. </div>
  9. .input 标准输入框样式
  10. .input-red 红色字体输入框样式
  11. .verification 验证码按钮绿色
  12. .verification-yellow 验证码按钮黄色
  13. .verification-rosered 验证码按钮玫瑰红色
  14. .verification-orange 验证码按钮橙色
  15. .verification-blue 验证码按钮蓝色
  16. .verification-red 验证码按钮红色
  17. 验证码按钮js
  18. var bt01 = document.getElementById("bt01"); 获取id
  19. bt01.onclick = function () { 点击事件
  20. var timer = setInterval(fun1, 1000); //设置定时器
  21. function fun1() {
  22. time--;
  23. if (time >= 0) {
  24. bt01.innerHTML = time+'s';
  25. } else {
  26. bt01.innerHTML = '重新发送验证码';
  27. bt01.disabled = false; //倒计时结束能够重新点击发送的按钮
  28. clearTimeout(timer); //清除定时器
  29. time = 60; //设置循环重新开始条件
  30. }
  31. }

特别说明