HTML DOM Button 對象
Button 對象
Button 對象代表 HTML <button> 元素。
訪問 Button 對象
您可以使用 getElementById() 訪問 <button> 元素:
var x = document.getElementById("myBtn");
創建 Button 對象
您可以使用 document.createElement() 方法創建 <button> 元素:
var x = document.createElement("BUTTON");
Button 對象屬性
屬性 | 描述 |
---|---|
autofocus | 設置或返回按鈕是否在頁面加載時自動獲得焦點。 |
disabled | 設置或返回按鈕是否被禁用。 |
form | 返回對包含按鈕的表單的引用。 |
formAction | 設置或返回按鈕的 formaction 屬性值。 |
formEnctype | 設置或返回按鈕的 formenctype 屬性值。 |
formMethod | 設置或返回按鈕的 formmethod 屬性值。 |
formNoValidate | 設置或返回是否應在提交時驗證表單數據。 |
formTarget | 設置或返回按鈕的 formtarget 屬性值。 |
name | 設置或返回按鈕 name 屬性的值。 |
type | 設置或返回按鈕的類型。 |
value | 設置或返回按鈕的 value 屬性的值。 |
相關頁面
HTML 參考手冊:HTML <button> 標簽