preventDefault()
noun
say it: “prih-VENT dih-FAWLT” /prɪˈvɛnt dɪˈfɔːlt/
The event method that stops the browser's usual action, such as a form loading a new page.
What does preventDefault() do in JavaScript?
preventDefault() — An Event method that cancels the browser's default action when the event is cancelable.
form.addEventListener("submit", event => {
event.preventDefault();
});
In a sentence
- “preventDefault() stopped the form reloading the page so fetch could send it.”
Level: Freelancer · More JavaScript terms at this level
Updated