Etiqueta htmlPara propiedad
Ejemplo
Devuelve el valor del atributo for de una etiqueta:
var x = document.getElementById("myLabel").htmlFor;
Definición y uso
La propiedad htmlFor establece o devuelve el valor del atributo for de una etiqueta.
El atributo for especifica a qué elemento de formulario está vinculada una etiqueta.
Compatibilidad con navegador
Property | |||||
---|---|---|---|---|---|
htmlFor | Yes | Yes | Yes | Yes | Yes |
Sintaxis
Devuelve la propiedad htmlFor:
labelObject.htmlFor
Establezca la propiedad htmlFor:
labelObject.htmlFor = id
Valores de propiedad
Value | Description |
---|---|
id | The id of the element the label is bound to |
Detalles técnicos
Valor devuelto: | Una cadena, que representa la identificación del elemento al que está vinculada la etiqueta |
---|
Más ejemplos
Ejemplo
Cambia el valor del atributo for de una etiqueta:
document.getElementById("myLabel").htmlFor = "newValue";
páginas relacionadas
Referencia HTML: HTML <etiqueta> para atributo
❮ Objeto de etiqueta