HTML DOM Label htmlFor property
Examples
Returns the value of the property for the label:
var x = document.getElementById("myLabel").htmlFor;
x The output is:
male
try it"
Definition and Usage
Value htmlFor property sets or returns lable for the property.
for attribute specifies the label to which you want to bind a form element.
Browser Support
All major browsers support form property.
grammar
Back htmlFor properties:
labelObject .htmlFor
Setting htmlFor properties:
labelObject .htmlFor= id
Property Value
值 | 描述 |
---|---|
id | label 要绑定的元素的 id。 |
technical details
return value: | String representing the id label to bind elements. |
---|
More examples
Examples
Change the value of the label value properties:
document.getElementById("myLabel").htmlFor="newValue";
try it"
related articles
HTML Reference Manual: HTML <label> for properties