首页 > 语言 > JavaScript > 正文

jquery设置按钮停顿3秒不可用

2024-05-06 16:02:22
字体:
来源:转载
供稿:网友
设置按钮停顿3秒不可用的方法有很多,下面为大家介绍下使用jquery是如何实现的

复制代码 代码如下:


<!DOCTYPE html>
<html>
<head>
<title> my name is lian lily</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script type="text/javascript">

var times = 0
function show(obj) {
$("#btn_"+obj).attr("disabled","disabled");//设置button不可用
times++;
if(times == 2){
alert(obj);
times = 0;
$("#btn_"+obj).removeAttr("disabled");
return ;
}
//$("#frm"+obj).submit();
setTimeout("show("+obj+")" , 3000);
}
</script>
</head>

<body>
<form action ='post.php' method="post">
<input type="button" value="提交1" />
</form>

<form action ='post.php' method="post">
<input type="button" value="提交2"/>
</form>
</body>
</html>

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表

图片精选