HTML <button> form 屬性
示例
位於表單之外(但仍是表單的一部分)的按鈕
<form action="/action_page.php" method="get" id="form1">
<label for="fname">名字:</label>
<input type="text" id="fname" name="fname"><br><br>
<label for="lname">姓:</label>
<input type="text" id="lname" name="lname">
</form>
<button type="submit" form="form1" value="Submit">提交</button>
自己動手試一試 »
定義和用法
form
屬性指定了按鈕所屬的表單。
此屬性的值必須等於同一文件中 ` <form>
` 元素的 `id
` 屬性。
瀏覽器支援
表格中的數字表示完全支援該屬性的第一個瀏覽器版本。
Attribute | |||||
---|---|---|---|---|---|
form | 10.0 | 16.0 | 4.0 | 5.1 | 9.5 |
語法
<button form="form_id">
屬性值
值 | 描述 |
---|---|
form_id | 指定了 <button> 元素所屬的表單元素。此屬性的值必須是同一文件中 <form> 元素的 id 屬性。 |
❮ HTML <button> 標籤