How to stop click from being triggered on a button when pressing enter with HTML?

Spread the love

Sometimes, we want to stop click from being triggered on a button when pressing enter with HTML.

In this article, we’ll look at how to stop click from being triggered on a button when pressing enter with HTML.

How to stop click from being triggered on a button when pressing enter with HTML?

To stop click from being triggered on a button when pressing enter with HTML, we set the button’s type attribute to button.

For instance, we write

<button type="button">Whatever</button>

to set the button’s type attribute to button to stop clicks when we press enter.

Conclusion

To stop click from being triggered on a button when pressing enter with HTML, we set the button’s type attribute to button.

Leave a Reply

Your email address will not be published.