(编辑:jimmy 日期: 2024/11/10 浏览:2)
做一个发送验证码按钮,点击后要60秒之后才能再次点击,利用原有的amazeui样式做的一些扩展,当然主题功能的代码全都是自己写的,也可以脱离amazeUi 自己完成这个功能按钮
代码如下:
<!DOCTYPE html> <meta name="description" content=""> <meta name="keywords" content=""> <link href="Amaze UI/css/amazeui.min.css" rel="stylesheet"> </head> <html> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">. <title>Examples</title> <body style="text-align: center;"> <input type="text" class="phone" /> <button type="button" class="am-btn am-btn-primary btn-loading-example" data-am-loading="{spinner: 'circle-o-notch', loadingText: '正在发送', resetText: '重新发送'}">发送动态验证码</button> <script src="jquery2.3.0.js"></script> <script src="Amaze UI/js/amazeui.min.js"></script> <script src="http://cdn.bootcss.com/layer/2.4/layer.js"></script> <script> var _interval; var bb = 90 function timedown(){ bb--; var cc = '重新发送('; $(".btn-loading-example").text(cc+bb+')'); if(bb<=0){ clearInterval(_interval); return bb=60; } } $('.btn-loading-example').click(function () { var phone = /^1[3|4|5|7|8][0-9]{9}$/; if(!phone.test($(".phone").val())) { layer.msg('无效的手机号码'); return false; } timedown(); _interval = setInterval(timedown,1000); var $btn = $(this) $btn.button('loading'); setTimeout(function(){ $btn.button('reset'); }, 60000); }); </script> </body> </html>