<!DOCTYPE html>
<
html
>
<
head
>
<
meta
charset
=
"utf-8"
>
<
title
>在线测试页面</
title
>
<
script
type
=
"text/javascript"
src
=
"http://code.jquery.com/jquery-1.9.1.js"
></
script
>
<
style
>
*{ padding:0;margin:0;font-size:12px; }
</
style
>
</
head
>
<
body
>
<
div
class
=
"d"
style
=
"width:98px;height:98px;border:1px solid red;"
><
p
>点击了 <
label
style
=
"color: #1689F5;"
>0</
label
> 次。</
p
><
em
style
=
"color: red;"
></
em
></
div
>
</
body
>
<
script
type
=
"text/javascript"
>
$(function(){
var t = 0,num=0;;
$(".d").click(function(){
if( num == 0 ){
t = new Date().getTime();
num+=1;
$(this).find("label").text(num);
}else{
var tt = new Date().getTime();
if( tt-t<=500 ){
// 一直点击
$(this).children("em").text("请勿频繁操作!");
setTimeout(function(){
$(".d").children("em").text("");
},500);
}else if(tt-t>500){
num+=1;
$(this).find("label").text(num);
}
t = tt;
}
});
});
</
script
>
</
html
>