Objet radio d'entrée HTML DOM
Objet radio d'entrée
L'objet Input Radio représente un élément HTML <input> avec type="radio".
Accéder à un objet radio d'entrée
Vous pouvez accéder à un élément <input> avec type="radio" en utilisant getElementById() :
Exemple
var x = document.getElementById("myRadio");
Astuce : Vous pouvez également accéder à <input type="radio"> en cherchant dans la collection d' éléments d'un formulaire.
Créer un objet radio d'entrée
Vous pouvez créer un élément <input> avec type="radio" en utilisant la méthode document.createElement() :
Exemple
var x = document.createElement("INPUT");
x.setAttribute("type", "radio");
Propriétés de l'objet radio d'entrée
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 |
Propriétés et événements standard
L'objet Input Radio prend également en charge les propriétés et les événements standard .
Pages connexes
Tutoriel HTML : Formulaires HTML
Référence HTML : balise HTML <input>
Référence HTML : attribut de type HTML <input>