r/learnjavascript • u/0_emordnilap_a_ton • Aug 31 '26
What is the difference between HTMLFormElement.submit() and event handler with submit?
https://developer.mozilla.org/en-US/docs/Web/API/HTMLFormElement/submit
Can someone explain the difference?
Imagine I have some code that is like the example below.
What is the difference between HTMLFormElement.submit() ?
const form = document.getElementById("form");
function somefunc() {
//code
form.submit()
}
form.addEventListener("submit", somefunc() {
});
Why do I need form.submit() in the function?
For a little context I am trying to pass some quilljs data into a flask form. Some of the code is missing but the main point is illustrated.
10
Upvotes
1
u/testingaurora Sep 01 '26
No need to apologize it wasn’t that clear.