Something like this would do the trick. Store the variable with the time of the last click, and then compare it when the user clicks on the link again. If the difference is <5 seconds, a warning is displayed
<a id='testLink' href="#">click here</a>
<script type='text/javascript'>
var lastClick = 0;
$("#testLink").click(function() {
var d = new Date();
var t = d.getTime();
if(t - lastClick < 5000) {
alert("LESS THAN 5 SECONDS!!!");
}
lastClick = t;
});
</script>
source
share