简体   繁体   中英

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>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM