Latest web development tutorials

HTML DOM Label htmlFor property

Label Object Reference Label objects

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

Internet ExplorerFirefoxOperaGoogle ChromeSafari

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


Label Object Reference Label objects