Bootstrap中点击后禁用按钮的最佳方法
来源:互联网 发布:正元软件 编辑:程序博客网 时间:2024/05/16 09:56
为了防止在Bootstrap中点击按钮多次提交,所以希望点击按钮后禁用按钮。
具体实现方法如下:
//禁用button
$('button').addClass('disabled'); // Disables visually
$('button').prop('disabled', true); // Disables visually + functionally
//禁用类型为button的input按钮
$('input[type=button]').addClass('disabled'); // Disables visually
$('input[type=button]').prop('disabled', true); // Disables visually + functionally
//禁用超链接
$('a').addClass('disabled'); // Disables visually
$('a').prop('disabled', true); // Does nothing
$('a').attr('disabled', 'disabled'); // Disables visually
将上面方法写入点击事件中即可,如:
$(".btn-check").click(function () {
$('button').addClass('disabled'); // Disables visually
$('button').prop('disabled', true); // Disables visually + functionally
});
js按钮点击后几秒内不可用
function timer(time) {
var btn = $("#sendButton");
btn.attr("disabled", true); //按钮禁止点击
btn.val(time <= 0 ? "发送动态密码" : ("" + (time) + "秒后可发送"));
var hander = setInterval(function() {
if (time <= 0) {
clearInterval(hander); //清除倒计时
btn.val("发送动态密码");
btn.attr("disabled", false);
return false;
}else {
btn.val("" + (time--) + "秒后可发送");
}
}, 1000);
}
//调用方法
timer(30);
- Bootstrap中点击后禁用按钮的最佳方法
- Bootstrap中点击后禁用按钮的最佳方法
- 点击jsp页面按钮后,禁用整个页面的方法
- 如何将按钮点击后禁用
- Bootstrap框架下按钮的禁用
- bootstrap中下拉菜单点击后不关闭的方法
- 在ASP.NET中点击一个按钮后让它变灰的简单方法
- 在ASP.NET中点击一个按钮后让它变灰的简单方法
- AlertDialog点击按钮后对话框不消失的处理方法
- AlertDialog点击按钮后对话框不消失的处理方法
- bootstrap Model 点击确定按钮后 转到新页面
- 点击一个按钮后禁用按钮,执行完事件后再启用按钮
- 点击一个按钮后禁用按钮,执行完事件后再启用按钮
- 点击提交按钮后按钮变灰色不可用状态的三种方法
- Android中点击按钮后隐藏输入法
- 另类办法,实现点击按钮后禁用,直到操作完成后恢复,防止重复操作,实用
- 禁用窗口的关闭按钮方法
- C# 禁用 关闭窗口 按钮的方法
- Linux的常用命令
- 简历制作(项目经验)
- 删除线性表中所有值为x的元素,要求时间复杂度为O(n),空间复杂度为O(1)
- mysql脚本
- 利用oracle生成年历
- Bootstrap中点击后禁用按钮的最佳方法
- 值得推荐的C/C++框架和库,包含很多开源项目 (真的很强大)
- Android网络编程(九)Retrofit2前篇[基本使用]
- 微博同步does multipart has image?
- ITEXT 目录生成的第二种方法
- 下拉刷新组件SwipeRefreshLayout
- 高并发的服务器模式
- 用C语言实现顺序表的增删查改和逆置
- android studio 连接手机(真机测试)windows