Đối tượng nút HTML DOM
Đối tượng nút
Đối tượng Nút đại diện cho một phần tử HTML <button>.
Truy cập một đối tượng nút
Bạn có thể truy cập phần tử <button> bằng cách sử dụng getElementById ():
Thí dụ
var x = document.getElementById("myBtn");
Tạo một đối tượng nút
Bạn có thể tạo một phần tử <button> bằng cách sử dụng phương thức document.createElement ():
Thí dụ
var x = document.createElement("BUTTON");
Thuộc tính đối tượng nút
Property | Description |
---|---|
autofocus | Sets or returns whether a button should automatically get focus when the page loads, or not |
disabled | Sets or returns whether a button is disabled, or not |
form | Returns a reference to the form that contains a button |
formAction | Sets or returns the value of the formaction attribute of a button |
formEnctype | Sets or returns the value of the formenctype attribute of a button |
formMethod | Sets or returns the value of the formmethod attribute of a button |
formNoValidate | Sets or returns whether the form-data should be validated or not, on submission |
formTarget | Sets or returns the value of the formtarget attribute of a button |
name | Sets or returns the value of the name attribute of a button |
type | Sets or returns the type of a button |
value | Sets or returns the value of the value attribute of a button |
Thuộc tính và sự kiện tiêu chuẩn
Đối tượng Nút cũng hỗ trợ các thuộc tính và sự kiện tiêu chuẩn .
Các trang liên quan
Tham chiếu HTML: thẻ HTML <button>