<body>
<div class="quick">
<p>
您的发言过快,请休息一下
</p>
</div>
<button id="send">发送</button>
</body>
<script>
//首先引入jQuery
// 检测button点击次数,如果在2S内超过5次则禁言,并提示
var clickNum = 0 // 点击的次数
var firstTime = ''
var clickTime = ''
$('#send').click(function() {
if (clickNum == 0) {
firstTime = new Date().getTime()
}
clickTime = new Date().getTime()
if (clickTime - firstTime <= 2000) {
clickNum++
console.log(clickNum)
if (clickNum >= 5) {
$('.quick').show()
$('#area').attr('disabled', true)
}
} else {
}
})
</script>