HTML button type 屬性
實例
兩個button 元素,一個是提交按鈕,另一個是重置按鈕:
<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>
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>
嘗試一下»
瀏覽器支持
所有主流瀏覽器都支持type 屬性。
定義和用法
type 屬性規定按鈕的類型。
提示:請始終為按鈕規定type屬性。 Internet Explorer 的默認類型是"button",而其他瀏覽器中(包括W3C 規範)的默認值是"submit"。
HTML 4.01 與HTML5之間的差異
NONE.
語法
<button type="button|submit|reset">
屬性值
值 | 描述 |
---|---|
submit | 該按鈕是提交按鈕(除了Internet Explorer,該值是其他瀏覽器的默認值)。 |
button | 該按鈕是可點擊的按鈕(Internet Explorer 的默認值)。 |
reset | 該按鈕是重置按鈕(清除表單數據)。 |
HTML <button>標籤