Is there a better jQuery solution to this.form.submit();?

前端 未结 8 486
醉梦人生
醉梦人生 2020-12-02 20:13

I want to trigger the submit event of the form the current element is in. A method I know works sometimes is:

this.form.submit();

I\'m wond

8条回答
  •  不思量自难忘°
    2020-12-02 20:40

    Similar to Matthew's answer, I just found that you can do the following:

    $(this).closest('form').submit();
    

    Wrong: The problem with using the parent functionality is that the field needs to be immediately within the form to work (not inside tds, labels, etc).

    I stand corrected: parents (with an s) also works. Thxs Paolo for pointing that out.

提交回复
热议问题