1. 程式人生 > >表單 HTML button 標籤

表單 HTML button 標籤

<button></button>

定義按鈕,在 <button> 元素內部,可以放置文字、影象等內容,這是該元素與使用 <input> 元素建立的按鈕之間的不同之處
提示:請始終為 <button> 元素規定 type 屬性,否則就是個花瓶。

屬性 描述
autofocus autofocus 頁面載入時 <input>元素應該自動獲得焦點
disabled
disabled 定義禁用的 <input> 元素
form form_id 定義 <input>所屬的一個或多個表單
formaction URL 規定當提交表單時向何處傳送表單資料。覆蓋 form 元素的 action 屬性。該屬性與 type=“submit” 配合使用。
formmethod get post 規定用於傳送表單資料的 HTTP 方法。覆蓋 form 元素的 method 屬性。該屬性與 type=“submit” 配合使用。
formnovalidate formnovalidate 布林屬性,當表單提交時不進行驗證。覆蓋 form 元素的 novalidate 屬性。該屬性與 type=“submit” 配合使用。
formtarget _blank _self _parent _top framename 規定表示提交表單後,在哪裡顯示接收到響應的名稱或關鍵詞,在何處開啟 action URL。覆蓋 form 元素的 target 屬性。該屬性與 type=“submit” 配合使用。
name
text 按鈕的名稱。在 JavaScript 中引用元素,或者在表單提交後引用表單資料。(PS:只有設定了 name 屬性的表單元素才能在提交表單時傳遞它們的值)。
value text 按鈕的初始值。可由指令碼進行修改
type button reset submit 按鈕的型別

submit 提交(除了 Internet Explorer,該值是其他瀏覽器的預設值)。
button 可點選(Internet Explorer 的預設值),可用於設定函式。
reset 重置(清除表單資料)。

<form action="demo_form.html" method="get">
  First name: <input type="text" name="fname"><br>
  Last name: <input type="text" name="lname"><br>
  <button type="submit" value="提交">提交</button>
  <button type="reset" value="重置">重置</button>
</form>