DEV Community

Cover image for When use preventDefault() in a dom?
Faisal Ahmed
Faisal Ahmed

Posted on

When use preventDefault() in a dom?

First case: When you create a form, inside the form, you create a button, and when the button has clicked.
Second case: Your inside the form or inside the div, button type or input type is submit.

-in this two cases, you use e.preventDefault();

otherwise, you can't see the output. Your output is ready but not show. It display too fast that you can't see it.

  • without using e.preventDefault();


  • with using e.preventDefault();

Top comments (0)