Sometimes, we want to prevent refresh of page when button inside form clicked.
In this article, we’ll look at how to prevent refresh of page when button inside form clicked.
How to prevent refresh of page when button inside form clicked?
To prevent refresh of page when button inside form clicked, we set the type attribute of the button to button
.
For instance, we write
<button type="button">Click</button>
to add a button in the form with the type attribute set to button
to prevent refresh of the page when we click on the button.
Conclusion
To prevent refresh of page when button inside form clicked, we set the type attribute of the button to button
.