Objet de temps d'entrée HTML DOM
Objet de temps d'entrée
L'objet Input Time représente un élément HTML <input> avec type="time".
Remarque : <input type="time"> ne s'affiche pas en tant que champ d'heure approprié dans IE11 et les versions antérieures.
Accéder à un objet de temps d'entrée
Vous pouvez accéder à un élément <input> avec type="time" en utilisant getElementById() :
Exemple
var x = document.getElementById("myTime");
Conseil : Vous pouvez également accéder à <input type="time"> en effectuant une recherche dans la collection d' éléments d'un formulaire.
Créer un objet de temps d'entrée
Vous pouvez créer un élément <input> avec type="time" en utilisant la méthode document.createElement() :
Exemple
var x = document.createElement("INPUT");
x.setAttribute("type", "time");
Propriétés de l'objet de temps d'entrée
Property | Description |
---|---|
autocomplete | Sets or returns the value of the autocomplete attribute of a time field |
autofocus | Sets or returns whether a time field should automatically get focus when the page loads |
defaultValue | Sets or returns the default value of a time field |
disabled | Sets or returns whether a time field is disabled, or not |
form | Returns a reference to the form that contains the time field |
list | Returns a reference to the datalist that contains the time field |
max | Sets or returns the value of the max attribute of the time field |
min | Sets or returns the value of the min attribute of the time field |
name | Sets or returns the value of the name attribute of a time field |
readOnly | Sets or returns whether the time field is read-only, or not |
required | Sets or returns whether the time field must be filled out before submitting a form |
step | Sets or returns the value of the step attribute of the time field |
type | Returns which type of form element the time field is |
value | Sets or returns the value of the value attribute of a time field |
Méthodes d'objet de temps d'entrée
Method | Description |
---|---|
select() | Selects the content of a time text field |
stepDown() | Decrements the value of the time field by a specified number |
stepUp() | Increments the value of the time field by a specified number |
Propriétés et événements standard
L'objet Input Time 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>