blob: 7e13885446310cabe3299d60c7239c9b68533bcd (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
---
title: form.submit
slug: Web/API/HTMLFormElement/submit
tags:
- API
- HTML DOM
- 参考
- 方法
- 表单元素
translation_of: Web/API/HTMLFormElement/submit
---
<p>{{ ApiRef() }}</p>
<p> <strong><code>HTMLFormElement.submit()</code></strong>用来提交表单。</p>
<p>这个方法和触发提交表单按钮很类似,但有所不同:</p>
<ul>
<li>No {{event("submit")}} event is raised. In particular, the form's {{domxref("GlobalEventHandlers.onsubmit", "onsubmit")}} event handler is not run.</li>
<li><a href="/en-US/docs/Web/Guide/HTML/HTML5/Constraint_validation">Constraint validation</a> is not triggered.</li>
</ul>
<p>如果一个表单控件(比如一个提交按钮)的 <code>name</code> 或 <code>id</code> 的值为 <code>submit</code>,则它将覆盖表单的 submit 方法.</p>
<h2 id="语法">语法</h2>
<pre class="syntaxbox notranslate"><em>HTMLFormElement</em>.submit()</pre>
<h2 id="例子">例子</h2>
<pre class="brush: js notranslate">document.forms["myform"].submit();
</pre>
<h2 id="规范">规范</h2>
<p><a href="https://html.spec.whatwg.org/multipage/forms.html#the-form-element">HTML Living standard: The form element</a></p>
<h2 id="浏览器兼容性">浏览器兼容性</h2>
<p>{{Compat("api.HTMLFormElement.submit")}}</p>
|