是   元素的特殊版本,被用来创建一个没有默认值的可点击按钮。 它已经在HTML5被 

<input type="button"> - HTML(超文本标记语言) 编辑

元素<input type="button"> 是  <input> 元素的特殊版本,被用来创建一个没有默认值的可点击按钮。 它已经在HTML5被 <button>元素取代

浏览器生成一个控件没有默认值的可点击按钮。该按钮上可有任何标签。该控件在不同的浏览器上,可能有不同的样式。

Content categoriesFlow content, phrasing content, Interactive content, listed, labelable, and submittable form-associated element, palpable content.
Permitted contentPhrasing content.
Tag omissionNone, both the starting and ending tag are mandatory.
Permitted parent elementsAny element that accepts phrasing content.
DOM interfaceHTMLButtonElement
元素属性行内元素

Attributes

This element can have any of the global attributes in addition to the following:

disabled

This Boolean attribute indicates that the user cannot interact with the button. If this attribute is not specified, the button inherits its setting from the containing element, for example <fieldset>; if there is no containing element with the disabled attribute set, then the button is enabled. The disabled control's value isn't submitted with the form and the click event will not be dispatched on disabled controls.

Firefox will, unlike other browsers, by default, persist the dynamic disabled state of a <button> across page loads. Use the autocomplete attribute to control this feature.

autofocus HTML5
This Boolean attribute lets you specify that the button should have input focus when the page loads, unless the user overrides it, for example by typing in a different control. Only one form-associated element in a document can have this attribute specified.
autocomplete
The use of this attribute on a <button> is nonstandard and Firefox-specific. By default, unlike other browsers, Firefox persists the dynamic disabled state of a <button> across page loads. Setting the value of this attribute to off (i.e., autocomplete="off") disables this feature.
form HTML5
The form element that the button is associated with (its form owner). The value of the attribute must be the id attribute of a <form> element in the same document. If this attribute is not specified, the <button> element must be a descendent of a form element. This attribute enables you to place <button> elements anywhere within a document, not just as descendents of their <form> elements.
formenctype
Since the input element is a submit button, the formenctype attribute specifies the type of content that is used to submit the form to the server. Possible values are:
  • application/x-www-form-urlencoded: The default value if the attribute is not specified.
  • multipart/form-data: This value is used if an <input> element is used with the type attribute set to file.
  • text/plain

If this attribute is specified, it overrides the enctype attribute of the element's form owner.

formaction HTML5
The URI of a program that processes the information submitted by the button. If specified, it overrides the action attribute of the button's form owner.
formmethod
Since the input element is a submit button, the formmethod attribute specifies the HTTP method that the browser uses to submit the form. Possible values are:
  • post: The data from the form is included in the body of the form and is sent to the server.
  • get: The data from the form is appended to the form attribute URI, with a '?' as a separator, and the resulting URI is sent to the server. Use this method when the form has no side-effects and contains only ASCII characters.

If specified, this attribute overrides the method attribute of the element's form owner.

formnovalidate
Since the input element is a submit button, the formnovalidateattribute specifies that the form is not to be validated when it is submitted. If this attribute is specified, it overrides the novalidate attribute of the element's form owner. This is a Boolean attribute.
formtarget
Since the input element is a submit button, the formtarget attribute is a name or keyword indicating where to display the response that is received after submitting the form. This is a name of, or keyword for, a browsing context (for example, tab, window, or inline frame). If this attribute is specified, it overrides the target attribute of the element's form owner. The following keywords have special meanings:
  • _self: Load the response into the same browsing context as the current one. This value is the default if the attribute is not specified.
  • _blank: Load the response into a new unnamed browsing context.
  • _parent: Load the response into the parent browsing context of the current one. If there is no parent, this option behaves the same way as _self.
  • _top: Load the response into the top-level browsing context (that is, the browsing context that is an ancestor of the current one, and has no parent). If there is no parent, this option behaves the same way as _self.
name
The name of the button, which is submitted with the form data.
type
The type of the button. Possible values are:
  • submit: The button submits the form data to the server. This is the default if the attribute is not specified, or if the attribute is dynamically changed to an empty or invalid value.
  • reset: The button resets all the controls to their initial values.
  • button: The button has no default behavior. It can have client-side scripts associated with the element's events, which are triggered when the events occur.
value
The initial value of the button.

举例

这创建一个新的按钮<input>元素,文本显示出 'Click me'。

<input type="button" value="Click me">

Specifications

SpecificationStatus
HTML Living Standard
<button>
Living Standard
HTML5
<button>
Recommendation
HTML 4.01 Specification
<button>
Recommendation

Browser compatibility

We're converting our compatibility data into a machine-readable JSON format. This compatibility table still uses the old format, because we haven't yet converted the data it contains. Find out how you can help!
FeatureGoogle ChromeFirefox (Gecko)

IE

OperaSafari
Basic support1.01.0 (1.7 or earlier)(Yes)(Yes)(Yes)
formenctype attribute9.04.0 (2.0)1010.6?
formmethod attribute9.04.0 (2.0)10??
autofocus attribute9.04.0 (2.0)109.65.0
formaction attribute9.04.0 (2.0)10??
FeatureAndroidFirefox 移动版(Gecko)IE 移动版Opera 移动版Safari 移动版
Basic support(Yes)1.0 (1.0)(Yes)(Yes)(Yes)
formenctype attribute?4.0 (2.0)???
formmethod attribute?4.0 (2.0)???
formaction attribute?4.0 (2.0)???

 

更多

 

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据

词条统计

浏览:122 次

字数:15247

最后编辑:6 年前

编辑次数:0 次

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文