Объект кнопки ввода HTML DOM
Объект кнопки ввода
Объект Input Button представляет HTML-элемент <input> с type="button".
Доступ к объекту кнопки ввода
Вы можете получить доступ к элементу <input> с type="button" с помощью getElementById():
Пример
var x = document.getElementById("myBtn");
Совет: Вы также можете получить доступ к <input type="button">, выполнив поиск в коллекции элементов формы.
Создайте объект кнопки ввода
Вы можете создать элемент <input> с type="button" с помощью метода document.createElement():
Пример
var x = document.createElement("INPUT");
x.setAttribute("type", "button");
Свойства объекта кнопки ввода
Property | Description |
---|---|
autofocus | Sets or returns whether an input button should automatically get focus when the page loads |
defaultValue | Sets or returns the default value of an input button |
disabled | Sets or returns whether an input button is disabled, or not |
form | Returns a reference to the form that contains the input button |
name | Sets or returns the value of the name attribute of an input button |
type | Returns which type of form element the input button is |
value | Sets or returns the value of the value attribute of an input button |
Стандартные свойства и события
Объект Input Button также поддерживает стандартные свойства и события .
Связанные страницы
Учебник по HTML: HTML-формы
Справочник по HTML: HTML-тег <input>
Справочник по HTML: HTML-атрибут типа <input>