[英]How can I make a button clickable only one time?
I want to create a button that gets disabled after one click/is just clickable one time... I couldnt find anything about it.我想创建一个按钮,单击一次后将被禁用/只能单击一次……我找不到任何相关信息。
Add a click event listener to the button which disables it.将点击事件侦听器添加到禁用它的按钮。
document.querySelector('button').addEventListener('click', function(){ this.disabled = true; })
<button>Button</button>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.