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)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay