html5的button标签时间限制点击?

html5的button标签时间限制点击?

1.我的html代码如下:


 <!DOCTYPE HTML>

    <html>

    <body>

    

    <button type="button">Click Me!</button>

    </body>

    </html>


    

 

2.我如何使用js,或者其他代码来限制点击?但不是一直限制点击,而是在我运行上面html页面后,开始倒计时,打个比方:在运行上面的页面后,这时我不能点击它,我需要等待一分钟或者三分钟后才能点击。这个问题应该非常简单,但是我不知道怎么做,抱歉请原谅。

3.提前感谢任何回复,给我这个陌生人予以帮助!


人到中年有点甜
浏览 411回答 2
2回答

繁星coding

设置按钮为 disable就点击不了<button id="btn" type="button" disable>Click Me!</button>然后过几分钟或者其他才能点击 你移除disable就可以了var btn = document.querySelector('#btn'), timer;clearTimeout(timer)timer = setTimeout(function () {&nbsp; &nbsp; btn.removeAttribute('disable');}, 3000)

紫衣仙女

var canClick=false;&nbsp; &nbsp; setTimeout(function(){&nbsp; &nbsp; &nbsp; &nbsp; canClick=true;&nbsp; &nbsp; },3000);&nbsp; &nbsp; document.querySelector('button').onclick=function(){&nbsp; &nbsp; &nbsp; &nbsp; if(!canClick){&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return false;&nbsp; &nbsp; &nbsp; &nbsp; }&nbsp; &nbsp; &nbsp; &nbsp; alert(1);&nbsp; &nbsp; }
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

JavaScript