submit event does not fire if submit initiated programmatically

后端 未结 2 1046
你的背包
你的背包 2020-11-30 12:37

I have a HTML form with button:

<
相关标签:
2条回答
  • 2020-11-30 13:26

    That's because you shouldn't just use the submit function, but trigger the submit like:

    $("#MyForm").trigger('submit');
    
    0 讨论(0)
  • 2020-11-30 13:26

    Browsers don't fire the form's onsubmit handler when you manually call form.submit().

    jQuery also mimicks used to mimick that (see this "wontfix" "bug" report).

    See also:

    • Should jQuery's $(form).submit(); not trigger onSubmit within the form tag?
    • JQuery: on submit doesn't work
    0 讨论(0)
提交回复
热议问题