FREE Web Template Download
HTML CSS JAVASCRIPT SQL PHP BOOTSTRAP JQUERY ANGULARJS TUTORIALS REFERENCES EXAMPLES Blog
 

Label htmlFor Property

Label Object Reference Label Object

Example

Return the value of the for attribute of a label:

var x = document.getElementById("myLabel").phpFor;

The result of x will be:

male
Try it Yourself »

Definition and Usage

The htmlFor property sets or returns the value of the for attribute of a label.

The for attribute specifies which form element a label is bound to.


Browser Support

Property
htmlFor Yes Yes Yes Yes Yes

Syntax

Return the htmlFor property:

labelObject.phpFor

Set the htmlFor property:

labelObject.phpFor=id

Property Values

Value Description
id The id of the element the label is bound to

Technical Details

Return Value: A String, representing the id of the element the label is bound to

More Examples

Example

Change the value of the value attribute of a label:

document.getElementById("myLabel").phpFor = "newValue";
Try it Yourself »

Related Pages

HTML reference: HTML <label> for attribute


Label Object Reference Label Object