Label htmlFor Attribute

Definition and Usage

htmlFor Sets or returns the value of the for attribute of the label (label).

label for Attribute Specify which form element the label is bound to.

See also:

HTML-Referenzhandbuch:HTML <label>-Tag

Example

Example 1

Return the value of the for attribute of the label:

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

Try It Yourself

Example 2

Change the value of the for attribute of the label:

document.getElementById("myLabel").htmlFor = "newValue";

Try It Yourself

Syntax

Return htmlFor Attribute:

labelObject.htmlFor

Set htmlFor Attribute:

labelObject.htmlFor = id

Attributwert

Wert Beschreibung
id id des Elements, dem das Label (label) zugeordnet ist.

Technische Details

Rückgabewert: Zeichenfolgenwert, der den id des Elements angibt, dem das Label (label) zugeordnet ist.

Browserunterstützung

Chrome Edge Firefox Safari Opera
Chrome Edge Firefox Safari Opera
Unterstützung Unterstützung Unterstützung Unterstützung Unterstützung

Verwandte Seiten

HTML-Referenzhandbuch:HTML <label> for-Attribut