I noticed that you can call submit() in event handlers of form elements. For example,
<input id="myInput" type="button" onclick="submit()" value="Test" />
clicking the button generated by the code above will submit the form. The funny thing is, I can’t call submit() outside the event handler. There is no submit member defined for the input element.(document.getElementById("myInput").submit is undefined.) So, where is this function defined, and where can I find a reference to this function?
It is described here in section 19.1.6:
and
So I guess it was already clear that the
submitfunction is the one of theform. And if the event handler is defined via an HTML attribute, then the scope chain are the element itself and its parents. But it is not standardized, so one should not rely on that behavior.