<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>




<input type="button" value="点击按钮生成随机数" id="sss">






    <script>




var sss = document.getElementById("sss");
var lock = false;
sss.onclick = function(){
  
    if(lock){
        alert("两秒后再试");
        return;
    }
    console.log(Math.random());
        lock = true;
    setTimeout(function(){
        lock = false;
    },2000);
};





    
    </script>
</body>
</html>