How to reliably submit an HTML form with JavaScript?

后端 未结 7 1588
面向向阳花
面向向阳花 2020-12-13 20:33

Is there a way to submit an HTML form using JavaScript that is guaranteed to work in all situations?

I elaborate. The common approach seems to be:

fo         


        
7条回答
  •  温柔的废话
    2020-12-13 20:47

    For a form named submit just calling its buttons click function works for me.

    document.forms[0].submit.click();  //where submit here is just the name of the button/input tied to the form.
    

提交回复
热议问题