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