Obiekt radiowy wejściowy HTML DOM
Wejście radiowe obiektu
Obiekt Input Radio reprezentuje element HTML <input> z type="radio".
Uzyskaj dostęp do wejściowego obiektu radiowego
Możesz uzyskać dostęp do elementu <input> z type="radio" za pomocą getElementById():
Przykład
var x = document.getElementById("myRadio");
Wskazówka: możesz również uzyskać dostęp do <input type="radio"> przeszukując kolekcję elementów formularza.
Utwórz wejściowy obiekt radiowy
Możesz utworzyć element <input> z type="radio" za pomocą metody document.createElement():
Przykład
var x = document.createElement("INPUT");
x.setAttribute("type", "radio");
Właściwości wejściowego obiektu radiowego
Property | Description |
---|---|
autofocus | Sets or returns whether a radio button should automatically get focus when the page loads |
checked | Sets or returns the checked state of a radio button |
defaultChecked | Returns the default value of the checked attribute |
defaultValue | Sets or returns the default value of a radio button |
disabled | Sets or returns whether the radio button is disabled, or not |
form | Returns a reference to the form that contains the radio button |
name | Sets or returns the value of the name attribute of a radio button |
required | Sets or returns whether the radio button must be checked before submitting a form |
type | Returns which type of form element the radio button is |
value | Sets or returns the value of the value attribute of the radio button |
Standardowe właściwości i zdarzenia
Obiekt Input Radio obsługuje również standardowe właściwości i zdarzenia .
Powiązane strony
Samouczek HTML: formularze HTML
Odniesienie HTML: tag HTML <input>
Odniesienie HTML: atrybut typu HTML <input>