点击事件里给button标签加一个自定义属性,存上次点击时间
追问:
求详细代码,JS 真心的没怎么做过
追答:
<input type=
"button"
id=
"submit"
value=
"提交"
>
<script>
$(document).ready(
function
(){
$(
"#submit"
).click(
function
(){
var
nowTime =
new
Date().getTime();
var
clickTime = $(
this
).attr(
"ctime"
);
if
( clickTime !=
‘undefined‘
&& (nowTime - clickTime < 5000)){
alert(
‘操作过于频繁,稍后再试‘
);
return
false
;
}
else
{
$(
this
).attr(
"ctime"
,nowTime);
alert(
‘提交成功‘
);
}
});
});
</script>
时间: 2024-11-03 21:09:10