“Submit is not a function” error in JavaScript

后端 未结 15 3183
遇见更好的自我
遇见更好的自我 2020-11-22 00:10

Can anyone tell me what is going wrong with this code? I tried to submit a form with JavaScript, but an error \".submit is not a function\" shown. See below for more details

15条回答
  •  我在风中等你
    2020-11-22 00:39

    If you have no opportunity to change name="submit" you can also submit form this way:

    function submitForm(form) {
        const submitFormFunction = Object.getPrototypeOf(form).submit;
        submitFormFunction.call(form);
    }
    

提交回复
热议问题