Is there an easy way to avoid double clicking a button?

  • 0
    There are many buttons that, when accidentally double-pressed without waiting for a response, give an unnecessary result.
    Is it possible to somehow simply wrap the button so as to avoid double clicks?
    JavaScript Ruby Reynolds, May 6, 2019

  • 2 Answers
  • 0
    async function handleClick(event) {
    event.target.setAttribute('disabled', '');

    await someTask();

    event.target.removeAttribute('disabled');
    }
    Anonymous

  • 0
    Better to do data validation in this case.
    Ivy Cabrera

Your Answer
To place the code, please use CodePen or similar tool. Thanks you!