HTML <button> form 屬性
定義和用法
form
屬性規定按鈕所屬的表單。
此屬性的值必須等于同一文檔中 <form> 元素的 id 屬性。
實例
位于表單外部的按鈕(但仍然是表單的一部分):
<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="提交">提交</button>
語法
<button form="form_id">
屬性值
值 | 描述 |
---|---|
form_id |
規定 <button> 元素所屬的表單元素。 該屬性的值必須是同一文檔中 <form> 元素的 id 屬性。 |
瀏覽器支持
Chrome | Edge | Firefox | Safari | Opera |
---|---|---|---|---|
Chrome | Edge | Firefox | Safari | Opera |
10.0 | 16.0 | 4.0 | 5.1 | 9.5 |
提示:<button> form 屬性是 HTML 5 中的新屬性。